ehsan-dashboards/dashboards/crm/.next/server/app/page.js

1 line
No EOL
109 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(()=>{var e={};e.id=931,e.ids=[931],e.modules={2934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},4580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},5869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},7285:(e,s,t)=>{"use strict";t.r(s),t.d(s,{GlobalError:()=>n.a,__next_app__:()=>m,originalPathname:()=>x,pages:()=>c,routeModule:()=>h,tree:()=>o}),t(8646),t(4403),t(996);var a=t(170),l=t(5002),r=t(3876),n=t.n(r),d=t(6299),i={};for(let e in d)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(i[e]=()=>d[e]);t.d(s,i);let o=["",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(t.bind(t,8646)),"/workspace/personal/crm/app/page.tsx"]}]},{layout:[()=>Promise.resolve().then(t.bind(t,4403)),"/workspace/personal/crm/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(t.t.bind(t,996,23)),"next/dist/client/components/not-found-error"]}],c=["/workspace/personal/crm/app/page.tsx"],x="/page",m={require:t,loadChunk:()=>Promise.resolve()},h=new a.AppPageRouteModule({definition:{kind:l.x.APP_PAGE,page:"/page",pathname:"/",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:o}})},9314:()=>{},2569:(e,s,t)=>{Promise.resolve().then(t.bind(t,9361))},8986:(e,s,t)=>{Promise.resolve().then(t.t.bind(t,3642,23)),Promise.resolve().then(t.t.bind(t,7586,23)),Promise.resolve().then(t.t.bind(t,7838,23)),Promise.resolve().then(t.t.bind(t,8057,23)),Promise.resolve().then(t.t.bind(t,7741,23)),Promise.resolve().then(t.t.bind(t,3118,23))},9361:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>eY});var a=t(7247),l=t(8964),r=t.n(l);let n=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),d=e=>{let s="",t=!1;for(let a of e){if("-"===a||"_"===a||a<=" "){t=s.length>0;continue}0===s.length?s+=a.toLowerCase():s+=t?a.toUpperCase():a,t=!1}return s},i=e=>{let s=d(e);return s.charAt(0).toUpperCase()+s.slice(1)},o=(...e)=>e.filter((e,s,t)=>!!e&&""!==e.trim()&&t.indexOf(e)===s).join(" ").trim(),c={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"},x=e=>{for(let s in e)if(s.startsWith("aria-")||"role"===s||"title"===s)return!0;return!1},m=(0,l.createContext)({}),h=()=>(0,l.useContext)(m),p=(0,l.forwardRef)(({color:e,size:s,width:t,height:a,strokeWidth:r,absoluteStrokeWidth:n,nonScalingStroke:d,className:i="",children:m,iconNode:p=[],icon:b={node:p,aliases:[],size:24},...u},g)=>{let{size:j=24,strokeWidth:f=2,absoluteStrokeWidth:y=!1,nonScalingStroke:N=!1,color:v="currentColor",className:w=""}=h()??{},k=!!m||x(u),[C,S,M=[]]=function(e,s={}){return function(e,s={}){let t=s.attributeNames??{},a=e=>t[e]??e,l=e.size??e.width??c.width,r=e.size??e.height??c.height,n=e.aliases?.filter(e=>"string"==typeof e&&""!==e.trim()).map(e=>`lucide-${e}`)??[],d=[...e.name?[`lucide-${e.name}`]:[],...n],i=s.className?.split(" ").filter(Boolean)??[],x=!1===s.includeDefaultClasses?o(...i):o("lucide",...d,...i),m=s.absoluteStrokeWidth?Number(s.strokeWidth??c["stroke-width"])*Number(e.size??e.width??c.width)/Number(s.size??s.width??c.width):s.strokeWidth??c["stroke-width"];return["svg",{...Object.entries(c).reduce((e,[s,t])=>(e[a(s)]=t,e),{}),..."color"in s&&s.color&&{[a("stroke")]:s.color},..."size"in s&&null!=s.size&&{[a("width")]:s.size,[a("height")]:s.size},..."width"in s&&null!=s.width&&{[a("width")]:s.width},..."height"in s&&null!=s.height&&{[a("height")]:s.height},[a("stroke-width")]:m,...x&&{[a("class")]:x},[a("viewBox")]:`0 0 ${l} ${r}`,...!1===s.hasA11yProp?{[a("aria-hidden")]:"true"}:{},..."attributes"in s&&s.attributes},e.node.map(e=>{let[t,l,r]=e,n=s.nonScalingStroke?{[a("vector-effect")]:"non-scaling-stroke",...l}:l;return r?[t,n,r]:[t,n]})]}(e,{...s,attributeNames:{...s.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}(b,{color:e??v,width:t??s??j,height:a??s??j,strokeWidth:r??f,absoluteStrokeWidth:n??y,nonScalingStroke:d??N,className:o(w,i),hasA11yProp:k,attributes:u});return(0,l.createElement)(C,{ref:g,...S},[...M.map(([e,s])=>(0,l.createElement)(e,s)),...Array.isArray(m)?m:[m]])});function b(e,s=[],t=[]){let a="string"==typeof e?function(e,s,t=[]){if(null==s)throw Error("[lucide]: iconNode is required when icon name is used");return{name:n(e),size:24,node:s,...t.length>0?{aliases:t}:{}}}(e,s,t):e,r=(0,l.forwardRef)(({className:e,...s},t)=>(0,l.createElement)(p,{ref:t,icon:a,className:e,...s}));return a.name&&(r.displayName=i(a.name)),r}let u={name:"layout-dashboard",size:24,node:[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]};u.node;let g=b(u),j={name:"calendar-check",size:24,node:[["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M16 2v3",key:"otl347"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]};j.node;let f=b(j),y={name:"git-pull-request",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]};y.node;let N=b(y),v={name:"graduation-cap",size:24,node:[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]};v.node;let w=b(v),k={name:"settings",size:24,node:[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};k.node;let C=b(k),S={name:"download",size:24,node:[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]};S.node;let M=b(S),z={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};z.node;let $=b(z),T={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};T.node;let P=b(T);function A({activeTab:e,setActiveTab:s,overdueCount:t=0,dueTodayCount:l=0,onOpenNewLead:n,onNewLead:d,onExportExcel:i,onImportExcel:o,onImportSuccess:c}){let x=r().useRef(null),[m,h]=r().useState(!1),p=async e=>{let s=e.target.files?.[0];if(!s)return;let t=new FormData;t.append("file",s),h(!0);try{let e=await fetch("/api/import",{method:"POST",body:t});if(e.ok)alert("فایل اکسل با موفقیت وارد و لیدها ثبت شدند."),c&&c();else{let s=await e.json();alert("خطا در ایمپورت اکسل: "+(s.error||"فرمت نامعتبر"))}}catch(e){alert("خطا در آپلود فایل: "+e.message)}finally{h(!1),e.target&&(e.target.value="")}},b=[{id:"dashboard",label:"داشبورد مدیریتی",icon:g},{id:"today",label:"وظایف امروز",icon:f,badge:l,isAlert:t>0},{id:"pipeline",label:"پایپ‌لاین فروش",icon:N},{id:"onboarding",label:"آنبوردینگ مشتریان",icon:w},{id:"settings",label:"تنظیمات و قوانین",icon:C}];return a.jsx("header",{className:"sticky top-0 z-40 bg-white/95 backdrop-blur-md border-b border-slate-200/80 shadow-xs",children:(0,a.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between h-16 gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3.5 shrink-0",children:[a.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-sky-600 via-sky-700 to-indigo-800 flex items-center justify-center text-white font-extrabold text-xl shadow-sm shadow-sky-500/20 ring-1 ring-sky-500/30",children:"E"}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:"font-extrabold text-base sm:text-lg text-slate-900 tracking-tight",children:["اکیپا ",a.jsx("span",{className:"text-sky-600",children:"CRM"})]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold bg-sky-50 text-sky-700 px-2 py-0.5 rounded-full border border-sky-200/70",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"اتاق‌های فرار"]})]}),a.jsx("p",{className:"text-[11px] text-slate-500 hidden sm:flex items-center gap-1 font-medium",children:"سیستم جذب، فروش و آنبوردینگ"})]})]}),a.jsx("nav",{className:"hidden md:flex items-center bg-slate-100/80 p-1 rounded-xl border border-slate-200/60",children:b.map(t=>{let l=t.icon,r=e===t.id;return(0,a.jsxs)("button",{onClick:()=>s(t.id),className:`flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs font-semibold transition-all duration-150 cursor-pointer ${r?"bg-white text-sky-700 shadow-xs font-bold":"text-slate-600 hover:text-slate-900 hover:bg-white/60"}`,children:[a.jsx(l,{className:`w-3.5 h-3.5 ${r?"text-sky-600":"text-slate-500"}`}),a.jsx("span",{children:t.label}),void 0!==t.badge&&t.badge>0&&a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.2 rounded-full tabular-nums text-white ${t.isAlert?"bg-rose-500 shadow-xs shadow-rose-500/30":"bg-amber-500"}`,children:t.badge})]},t.id)})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("input",{type:"file",ref:x,onChange:p,accept:".xlsx,.xls",className:"hidden"}),(0,a.jsxs)("button",{onClick:i,title:"دریافت فایل اکسل لیدها",className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-slate-700 bg-white hover:bg-slate-50 border border-slate-200 rounded-lg shadow-xs hover:border-slate-300 transition-all cursor-pointer",children:[a.jsx(M,{className:"w-3.5 h-3.5 text-emerald-600"}),a.jsx("span",{children:"خروجی اکسل"})]}),(0,a.jsxs)("button",{onClick:()=>{x.current?x.current.click():o&&o()},disabled:m,title:"بارگذاری فایل اکسل",className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-slate-700 bg-white hover:bg-slate-50 border border-slate-200 rounded-lg shadow-xs hover:border-slate-300 transition-all cursor-pointer",children:[a.jsx($,{className:"w-3.5 h-3.5 text-indigo-600"}),a.jsx("span",{children:m?"در حال ورود...":"ورودی اکسل"})]}),(0,a.jsxs)("button",{onClick:n||d||(()=>{}),className:"inline-flex items-center gap-1.5 px-3.5 py-1.5 text-xs font-bold text-white bg-sky-600 hover:bg-sky-700 active:bg-sky-800 rounded-lg shadow-xs shadow-sky-600/20 hover:shadow-sm transition-all cursor-pointer",children:[a.jsx(P,{className:"w-4 h-4 stroke-[2.5]"}),a.jsx("span",{children:"ثبت لید جدید"})]})]})]}),a.jsx("div",{className:"flex md:hidden items-center justify-between py-2 border-t border-slate-100 overflow-x-auto gap-2",children:b.map(t=>{let l=t.icon,r=e===t.id;return(0,a.jsxs)("button",{onClick:()=>s(t.id),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-semibold whitespace-nowrap cursor-pointer transition-all ${r?"bg-sky-50 text-sky-700 border border-sky-200":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(l,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.label}),void 0!==t.badge&&t.badge>0&&a.jsx("span",{className:"text-[10px] font-bold px-1 rounded-full bg-rose-500 text-white tabular-nums",children:t.badge})]},t.id)})})]})})}let _={name:"users",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]};_.node;let L=b(_),D={name:"flame",size:24,node:[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]]};D.node;let O=b(D),R={name:"clock-alert",size:24,node:[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M20 12v5",key:"12wsvk"}],["path",{d:"M20 21h.01",key:"1p6o6n"}],["path",{d:"M21.25 8.2A10 10 0 1 0 16 21.16",key:"17fp9f"}]]};R.node;let I=b(R),q={name:"award",size:24,node:[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]};q.node;let H=b(q),E={name:"sparkles",size:24,node:[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],aliases:["stars"]};E.node;let F=b(E),V={name:"chevron-left",size:24,node:[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]};V.node;let W=b(V),J={name:"chart-column",size:24,node:[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],aliases:["bar-chart-3"]};J.node;let B=b(J),K={name:"shield-alert",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]};K.node;let G=b(K),Q={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};Q.node;let U=b(Q),X={name:"phone-call",size:24,node:[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]};X.node;let Z=b(X),Y={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};Y.node;let ee=b(Y);function es({stats:e={},funnel:s=[],topObjections:t=[],recentActivities:l=[],onSelectLead:r,onGoToTodayTasks:n,onNavigateTab:d}){let i=e?.stats||e||{},o=s?.length?s:e?.funnel||[],c=t?.length?t:e?.topObjections||[],x=l?.length?l:e?.recentActivities||[],m=n||(()=>d&&d("today")),h=[{title:"کل سرنخ‌های ثبت‌شده",value:(i.totalLeads||0).toLocaleString("fa-IR"),desc:"مجموعه‌های اتاق فرار در سامانه",icon:L,color:"text-indigo-600",bgColor:"bg-indigo-50/80 ring-1 ring-indigo-500/20",border:"border-slate-200/80"},{title:"لیدهای داغ و اولویت بالا",value:(i.warmLeads||0).toLocaleString("fa-IR"),desc:`${Math.round((i.warmLeads||0)/(i.totalLeads||1)*100)}% از کل فرصت‌ها`,icon:O,color:"text-rose-600",bgColor:"bg-rose-50/80 ring-1 ring-rose-500/20",border:"border-slate-200/80"},{title:"پیگیری‌های معوق و امروز",value:(i.dueTodayCount||0).toLocaleString("fa-IR"),desc:`${i.overdueCount||0} مورد نیازمند تماس فوری`,icon:I,color:(i.overdueCount||0)>0?"text-amber-600":"text-emerald-600",bgColor:(i.overdueCount||0)>0?"bg-amber-50/80 ring-1 ring-amber-500/20":"bg-emerald-50/80 ring-1 ring-emerald-500/20",border:(i.overdueCount||0)>0?"border-amber-200":"border-slate-200/80",action:m},{title:"نرخ تبدیل نهایی (Won)",value:`${i.conversionRate||0}٪`,desc:`${i.closedWonCount||0} قرارداد موفق اکیپا`,icon:H,color:"text-emerald-600",bgColor:"bg-emerald-50/80 ring-1 ring-emerald-500/20",border:"border-slate-200/80"}];return(0,a.jsxs)("div",{className:"space-y-6",children:[a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:h.map((e,s)=>{let t=e.icon;return a.jsx("div",{onClick:e.action,className:`bg-white p-5 rounded-2xl border ${e.border} shadow-xs hover:shadow-md transition-all duration-200 group ${e.action?"cursor-pointer":""}`,children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("p",{className:"text-xs font-bold text-slate-500 mb-1",children:e.title}),a.jsx("h3",{className:"text-2xl font-black text-slate-900 tabular-nums tracking-tight",children:e.value}),a.jsx("p",{className:"text-[11px] font-medium text-slate-500 mt-1",children:e.desc})]}),a.jsx("div",{className:`p-3 rounded-xl ${e.bgColor} transition-transform group-hover:scale-105 duration-200`,children:a.jsx(t,{className:`w-5 h-5 ${e.color}`})})]})},s)})}),(0,a.jsxs)("div",{className:"bg-gradient-to-r from-slate-900 via-sky-950 to-indigo-950 text-white rounded-2xl p-6 shadow-sm border border-slate-800 relative overflow-hidden",children:[a.jsx("div",{className:"absolute top-0 right-0 -mt-10 -mr-10 w-48 h-48 bg-sky-500/10 rounded-full blur-3xl pointer-events-none"}),(0,a.jsxs)("div",{className:"relative z-10 flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"inline-flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-sky-300 bg-sky-900/60 border border-sky-700/50 px-2.5 py-0.5 rounded-full",children:[a.jsx(F,{className:"w-3 h-3 text-sky-400"}),"عملکرد رشد و فروش اتاق‌های فرار در اکیپا"]}),(0,a.jsxs)("h3",{className:"text-lg sm:text-xl font-black text-white",children:["گردش مالی جذب‌شده: ",a.jsx("span",{className:"tabular-nums font-mono-num",children:(i.totalSalesAll||0).toLocaleString("fa-IR")})," تومان"]}),(0,a.jsxs)("p",{className:"text-xs text-slate-300",children:["فروش ماه گذشته مجموعه‌های عضو اکیپا:"," ",(0,a.jsxs)("strong",{className:"text-emerald-400 font-bold tabular-nums",children:[(i.totalSalesLastMonth||0).toLocaleString("fa-IR")," تومان"]})]})]}),a.jsx("div",{className:"flex items-center gap-3 shrink-0",children:(0,a.jsxs)("button",{onClick:m,className:"bg-white hover:bg-slate-50 text-slate-900 px-4 py-2 rounded-xl text-xs font-bold shadow-xs transition-all flex items-center gap-1.5 cursor-pointer active:scale-98",children:[a.jsx(f,{className:"w-4 h-4 text-sky-600"}),(0,a.jsxs)("span",{children:["مشاهده کارتابل امروز (",i.dueTodayCount||0,")"]}),a.jsx(W,{className:"w-3.5 h-3.5 text-slate-400"})]})})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,a.jsxs)("div",{className:"lg:col-span-2 bg-white rounded-2xl border border-slate-200/80 p-6 shadow-xs",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-5",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx(B,{className:"w-4 h-4 text-sky-600"}),a.jsx("h3",{className:"text-sm font-bold text-slate-900",children:"قیف فروش و مراحل پایپ‌لاین"})]}),a.jsx("p",{className:"text-[11px] text-slate-500 mt-0.5",children:"توزیع لیدها در مراحل ۷ گانه تا جذب و لوپ دوره‌ای"})]}),(0,a.jsxs)("span",{className:"text-xs font-bold text-slate-500 bg-slate-100 px-2.5 py-1 rounded-full tabular-nums",children:["مجموع: ",i.totalLeads||0]})]}),a.jsx("div",{className:"space-y-3.5",children:o.map((e,s)=>{let t="bg-sky-500",l="bg-sky-50 text-sky-700 border-sky-200";return e.stage.includes("موفق")?(t="bg-emerald-500",l="bg-emerald-50 text-emerald-700 border-emerald-200"):e.stage.includes("ناموفق")||e.stage.includes("بایگانی")?(t="bg-slate-400",l="bg-slate-50 text-slate-700 border-slate-200"):(e.stage.includes("گرم")||e.stage.includes("مذاکره"))&&(t="bg-rose-500",l="bg-rose-50 text-rose-700 border-rose-200"),(0,a.jsxs)("div",{className:"space-y-1.5 group",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center text-xs",children:[a.jsx("span",{className:"font-bold text-slate-700",children:e.stage}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full border tabular-nums ${l}`,children:[e.count," مجموعه"]}),(0,a.jsxs)("span",{className:"text-slate-400 font-semibold tabular-nums w-8 text-left",children:[e.percentage,"%"]})]})]}),a.jsx("div",{className:"w-full bg-slate-100 rounded-full h-2 overflow-hidden",children:a.jsx("div",{className:`h-2 rounded-full transition-all duration-500 ${t}`,style:{width:`${Math.max(e.percentage,e.count>0?6:0)}%`}})})]},s)})})]}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200/80 p-6 shadow-xs",children:[(0,a.jsxs)("h3",{className:"text-sm font-bold text-slate-900 mb-4 flex items-center gap-2",children:[a.jsx(O,{className:"w-4 h-4 text-rose-500"}),"وضعیت دمای لیدها (Lead Temperature)"]}),(0,a.jsxs)("div",{className:"space-y-2.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-xl bg-rose-50/70 border border-rose-200/60",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-rose-500 animate-pulse"}),a.jsx("span",{className:"text-xs font-bold text-rose-950",children:"لیدهای داغ و گرم"})]}),a.jsx("span",{className:"text-sm font-black text-rose-700 tabular-nums",children:i.warmLeads||0})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-xl bg-amber-50/70 border border-amber-200/60",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500"}),a.jsx("span",{className:"text-xs font-bold text-amber-950",children:"خنثی / در حال بررسی"})]}),a.jsx("span",{className:"text-sm font-black text-amber-700 tabular-nums",children:i.neutralLeads||0})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-xl bg-slate-50/70 border border-slate-200/60",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-slate-400"}),a.jsx("span",{className:"text-xs font-bold text-slate-800",children:"سرد / کم‌تعامل"})]}),a.jsx("span",{className:"text-sm font-black text-slate-700 tabular-nums",children:i.coldLeads||0})]})]})]}),(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200/80 p-6 shadow-xs",children:[a.jsx("div",{className:"flex items-center justify-between mb-3",children:(0,a.jsxs)("h3",{className:"text-sm font-bold text-slate-900 flex items-center gap-2",children:[a.jsx(G,{className:"w-4 h-4 text-amber-500"}),"اعتراضات پرتکرار مدیران"]})}),0===c.length?a.jsx("p",{className:"text-xs text-slate-400 py-3 text-center",children:"هیچ اعتراضی در تماس‌ها ثبت نشده است."}):a.jsx("div",{className:"space-y-2",children:c.slice(0,4).map((e,s)=>(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs p-2.5 rounded-xl bg-slate-50 border border-slate-100 hover:border-slate-200 transition-all",children:[a.jsx("span",{className:"font-semibold text-slate-700 truncate max-w-[180px]",children:e.name}),(0,a.jsxs)("span",{className:"font-bold text-[10px] bg-slate-200 text-slate-800 px-2 py-0.5 rounded-full tabular-nums",children:[e.count," مورد"]})]},s))})]})]})]}),(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200/80 p-6 shadow-xs",children:[(0,a.jsxs)("h3",{className:"text-sm font-bold text-slate-900 mb-4 flex items-center gap-2",children:[a.jsx(I,{className:"w-4 h-4 text-indigo-500"}),"آخرین فعالیت‌ها و لاگ تعاملات ثبت‌شده"]}),0===x.length?a.jsx("p",{className:"text-xs text-slate-400 text-center py-6",children:"هنوز فعالیتی ثبت نشده است."}):a.jsx("div",{className:"divide-y divide-slate-100",children:x.map(e=>{let s=U,t="text-sky-600 bg-sky-50 border-sky-200/60";return"call"===e.type?(s=Z,t="text-emerald-600 bg-emerald-50 border-emerald-200/60"):"stage_change"===e.type?(s=ee,t="text-purple-600 bg-purple-50 border-purple-200/60"):"sms"===e.type&&(s=U,t="text-indigo-600 bg-indigo-50 border-indigo-200/60"),(0,a.jsxs)("div",{className:"py-3.5 flex items-start justify-between gap-3 text-xs first:pt-0 last:pb-0",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:`p-2 rounded-xl ${t} border shrink-0 mt-0.5`,children:a.jsx(s,{className:"w-4 h-4"})}),(0,a.jsxs)("div",{children:[e.lead&&a.jsx("button",{onClick:()=>r&&r(e.lead.id),className:"font-bold text-sky-700 hover:text-sky-800 inline-block mb-0.5 cursor-pointer",children:e.lead.name}),a.jsx("p",{className:"text-slate-600 leading-relaxed whitespace-pre-line",children:e.content})]})]}),a.jsx("span",{className:"text-[11px] font-medium text-slate-400 shrink-0 tabular-nums",children:new Date(e.createdAt).toLocaleDateString("fa-IR")})]},e.id)})})]})]})}let et={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};et.node;let ea=b(et),el={name:"columns-3",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],aliases:["panels-left-right"]};el.node;let er=b(el),en={name:"table",size:24,node:[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]};en.node;let ed=b(en),ei=[{currentStage:"ارتباط اولیه",nextStage:"ارسال پرپوزال",delayDays:0,channel:"پیامک",action:"ارسال پرپوزال اکیپا",smsTag:"خوش آمدگویی"},{currentStage:"ارسال پرپوزال",nextStage:"پیگیری سرد ۱",delayDays:1,channel:"پیامک",action:"پیامک راه‌حل اکیپا برای نقطه درد + دعوت به اقدام",smsTag:"خوش آمدگویی"},{currentStage:"مشاهده پرپوزال",nextStage:"پیگیری گرم ۱",delayDays:2,channel:"تماس",action:"رفع ابهام + پیشنهاد دو هفته‌ی رایگان اکیپا",smsTag:"اطلاع از آپدیت‌ها"},{currentStage:"پیگیری سرد ۱",nextStage:"پیگیری گرم ۱",delayDays:2,channel:"تماس",action:"پیگیری سوالات، مشاهده‌ی اطلاعات ارسالی، پیشنهاد دو هفته‌ی رایگان",smsTag:"اطلاع از آپدیت‌ها"},{currentStage:"پیگیری گرم ۱",nextStage:"پیگیری سرد ۲",delayDays:3,channel:"پیامک",action:"ارسال آمار موفقیت اکیپا و آمار لاین مجموعه با لینک",smsTag:"آمار موفقیت‌های اکیپا"},{currentStage:"پیگیری سرد ۲",nextStage:"پیگیری گرم ۲",delayDays:3,channel:"تماس",action:"جویا شدن علت عدم همکاری و رفع موانع اتصال",smsTag:"آمار موفقیت‌های اکیپا"},{currentStage:"پیگیری گرم ۲",nextStage:"لوپ پیامکی",delayDays:10,channel:"پیامک",action:"ورود به لوپ پیامکی خودکار اکیپا",smsTag:"آمار موفقیت‌های اکیپا"},{currentStage:"لوپ پیامکی",nextStage:"لوپ پیامکی",delayDays:10,channel:"پیامک",action:"پیامک لوپ دوره‌ای (ارسال آمار و نکات افزایش رزرو)",smsTag:"طبق جدول لوپ"}],eo=["ارتباط اولیه","ارسال پرپوزال","مشاهده پرپوزال","پیگیری سرد ۱","پیگیری گرم ۱","پیگیری سرد ۲","پیگیری گرم ۲","لوپ پیامکی","بسته شد / موفق","بایگانی / ناموفق"].map(e=>({stage:e,name:e})),ec=[{objection:"درصدی کار نمی‌کنیم / کمیسیون بالاست",rebuttal:"اکیپا کمیسیون را از افزایش فروش سانس‌های خالی پوشش می‌دهد؛ دو هفته اول بدون هیچ ریسک و هزینه‌ای تست کنید.",action:"ارسال ماشین‌حساب سودآوری اکیپا"},{objection:"خودمون سایت داریم و فروش کافیه",rebuttal:"سایت شما مخاطب ثابت شماست؛ اکیپا مسافران و کاربران جدید کشف‌نشده را به سانس‌های خالی وسط هفته شما می‌آورد.",action:"ارسال نمونه کیس‌استادی افزایش ۳۰٪ رزروهای خالی"},{objection:"نیاز به هماهنگی با شریک دارم",rebuttal:"کاملاً درسته؛ پرپوزال خلاصه تک‌صفحه‌ای اختصاصی برای ارائه به شریک برایتان ارسال شد، کی برای جلسه مشترک مناسب است؟",action:"تنظیم جلسه آنلاین ۵ دقیقه‌ای با شرکا"},{objection:"وقت پر کردن سانس و کار با پنل رو نداریم",rebuttal:"مدیریت و همگام‌سازی سانس‌ها از طریق وب‌هوک و پشتیبانی اکیپا کاملاً اتوماتیک انجام می‌شود، صفر بار کاری برای پرسنل شما.",action:"توضیح سیستم سینک خودکار سانس‌ها"}];function ex(e){if(!e)return{overdue:!1,days:0};let s=new Date(e),t=new Date;s.setHours(0,0,0,0),t.setHours(0,0,0,0);let a=Math.floor((t.getTime()-s.getTime())/864e5);return{overdue:a>0,days:a>0?a:0}}function em({leads:e,onSelectLead:s,onAdvanceLead:t,onRefresh:r}){let[n,d]=(0,l.useState)("kanban"),[i,o]=(0,l.useState)(""),[c,x]=(0,l.useState)("all"),[m,h]=(0,l.useState)("all"),[p,b]=(0,l.useState)("all"),u=e.filter(e=>{let s=e.name.toLowerCase().includes(i.toLowerCase())||e.ownerName.toLowerCase().includes(i.toLowerCase())||e.ownerPhone.includes(i)||e.city&&e.city.includes(i),t="all"===c||e.city===c,a="all"===m||e.temperature===m,l="all"===p||e.stage===p;return s&&t&&a&&l}),g=Array.from(new Set(e.map(e=>e.city).filter(Boolean))),j=async(e,s)=>{e.stopPropagation(),t?await t(s):await fetch(`/api/leads/${s}/advance`,{method:"POST"}),r()};return(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"bg-white p-4 rounded-2xl border border-slate-200 shadow-sm flex flex-col md:flex-row items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2.5 w-full md:w-auto",children:[(0,a.jsxs)("div",{className:"relative w-full sm:w-64",children:[a.jsx(ea,{className:"w-4 h-4 text-slate-400 absolute right-3 top-2.5"}),a.jsx("input",{type:"text",placeholder:"جستجوی نام مجموعه، مدیر، شماره...",value:i,onChange:e=>o(e.target.value),className:"w-full pl-3 pr-9 py-1.5 text-xs border border-slate-300 rounded-xl focus:ring-2 focus:ring-sky-500"})]}),(0,a.jsxs)("select",{value:c,onChange:e=>x(e.target.value),className:"border border-slate-300 rounded-xl px-2.5 py-1.5 text-xs text-slate-700 focus:ring-2 focus:ring-sky-500",children:[a.jsx("option",{value:"all",children:"همه شهرها"}),g.map(e=>a.jsx("option",{value:e,children:e},e))]}),(0,a.jsxs)("select",{value:m,onChange:e=>h(e.target.value),className:"border border-slate-300 rounded-xl px-2.5 py-1.5 text-xs text-slate-700 focus:ring-2 focus:ring-sky-500",children:[a.jsx("option",{value:"all",children:"همه دماها"}),a.jsx("option",{value:"گرم",children:"فقط لیدهای گرم"}),a.jsx("option",{value:"خنثی",children:"فقط لیدهای خنثی"}),a.jsx("option",{value:"سرد",children:"فقط لیدهای سرد"})]}),"table"===n&&(0,a.jsxs)("select",{value:p,onChange:e=>b(e.target.value),className:"border border-slate-300 rounded-xl px-2.5 py-1.5 text-xs text-slate-700 focus:ring-2 focus:ring-sky-500",children:[a.jsx("option",{value:"all",children:"همه مراحل پایپ‌لاین"}),eo.map(e=>{let s="string"==typeof e?e:e.stage;return a.jsx("option",{value:s,children:s},s)})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 bg-slate-100 p-1 rounded-xl self-end md:self-auto",children:[(0,a.jsxs)("button",{onClick:()=>d("kanban"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-bold transition-all ${"kanban"===n?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:text-slate-900"}`,children:[a.jsx(er,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:"کانبان"})]}),(0,a.jsxs)("button",{onClick:()=>d("table"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-bold transition-all ${"table"===n?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:text-slate-900"}`,children:[a.jsx(ed,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:"جدول"})]})]})]}),"kanban"===n&&a.jsx("div",{className:"flex gap-4 overflow-x-auto pb-6 pt-1",children:eo.map(e=>{let t="string"==typeof e?e:e.stage,l=u.filter(e=>e.stage===t),r="bg-slate-100 text-slate-800";return"ارتباط اولیه"===t&&(r="bg-sky-100 text-sky-900"),t.includes("پرپوزال")&&(r="bg-blue-100 text-blue-900"),t.includes("گرم")&&(r="bg-rose-100 text-rose-900"),t.includes("سرد")&&(r="bg-slate-200 text-slate-800"),"لوپ پیامکی"===t&&(r="bg-indigo-100 text-indigo-900"),"بسته شد / موفق"===t&&(r="bg-emerald-100 text-emerald-900"),"بایگانی / ناموفق"===t&&(r="bg-gray-200 text-gray-700"),(0,a.jsxs)("div",{className:"w-72 shrink-0 bg-slate-50/70 rounded-2xl border border-slate-200 p-3 flex flex-col max-h-[calc(100vh-220px)]",children:[(0,a.jsxs)("div",{className:`p-2.5 rounded-xl ${r} flex items-center justify-between mb-3 shadow-sm`,children:[a.jsx("h4",{className:"font-bold text-xs",children:t}),a.jsx("span",{className:"text-xs font-extrabold bg-white/70 px-2 py-0.5 rounded-full",children:l.length})]}),a.jsx("div",{className:"space-y-2.5 overflow-y-auto flex-1 pr-0.5 pl-0.5",children:0===l.length?a.jsx("div",{className:"text-center py-8 text-[11px] text-slate-400",children:"موردی در این مرحله نیست"}):l.map(e=>{let l=e.nextFollowupAt&&ex(new Date(e.nextFollowupAt));return(0,a.jsxs)("div",{onClick:()=>s(e.id),className:"bg-white p-3.5 rounded-xl border border-slate-200 hover:border-sky-300 shadow-sm hover:shadow transition-all cursor-pointer space-y-2.5",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("h5",{className:"font-bold text-slate-900 text-xs",children:e.name}),(0,a.jsxs)("p",{className:"text-[11px] text-slate-500 mt-0.5",children:[e.city," ",e.district?`• ${e.district}`:""]})]}),a.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${"گرم"===e.temperature?"bg-rose-100 text-rose-700":"خنثی"===e.temperature?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"}`,children:e.temperature})]}),e.rooms&&e.rooms.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1",children:e.rooms.map(e=>a.jsx("span",{className:"text-[10px] bg-slate-100 text-slate-600 px-1.5 py-0.2 rounded",children:e.title},e.id))}),(0,a.jsxs)("div",{className:"text-[11px] bg-slate-50 p-2 rounded-lg text-slate-600 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"font-semibold",children:["اقدام: ",e.nextChannel]}),l&&a.jsx("span",{className:"text-[9px] font-bold bg-rose-500 text-white px-1 py-0.2 rounded",children:"تاخیر"})]}),a.jsx("p",{className:"text-[10px] text-slate-500 line-clamp-1",children:e.nextAction})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between pt-1",children:[(0,a.jsxs)("span",{className:"text-[10px] text-slate-400",children:["مدیر: ",e.ownerName]}),"بسته شد / موفق"!==t&&"بایگانی / ناموفق"!==t&&(0,a.jsxs)("button",{onClick:s=>j(s,e.id),title:"مرحله بعد",className:"flex items-center gap-1 text-[10px] font-bold bg-sky-50 hover:bg-sky-100 text-sky-700 px-2 py-1 rounded-md border border-sky-200 transition-colors",children:[a.jsx("span",{children:"مرحله بعد"}),a.jsx(W,{className:"w-3 h-3"})]})]})]},e.id)})})]},t)})}),"table"===n&&a.jsx("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:a.jsx("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-right text-xs",children:[a.jsx("thead",{className:"bg-slate-50 text-slate-700 border-b border-slate-200 font-bold",children:(0,a.jsxs)("tr",{children:[a.jsx("th",{className:"py-3 px-4",children:"نام مجموعه"}),a.jsx("th",{className:"py-3 px-4",children:"شهر و منطقه"}),a.jsx("th",{className:"py-3 px-4",children:"مدیر و شماره"}),a.jsx("th",{className:"py-3 px-4",children:"مرحله فعلی"}),a.jsx("th",{className:"py-3 px-4",children:"دما"}),a.jsx("th",{className:"py-3 px-4",children:"اقدام و کانال بعدی"}),a.jsx("th",{className:"py-3 px-4",children:"تاریخ پیگیری"}),a.jsx("th",{className:"py-3 px-4 text-center",children:"عملیات"})]})}),a.jsx("tbody",{className:"divide-y divide-slate-100",children:0===u.length?a.jsx("tr",{children:a.jsx("td",{colSpan:8,className:"py-8 text-center text-slate-400",children:"هیچ موردی با فیلترهای انتخابی یافت نشد."})}):u.map(e=>{let t=e.nextFollowupAt&&ex(new Date(e.nextFollowupAt));return(0,a.jsxs)("tr",{onClick:()=>s(e.id),className:"hover:bg-slate-50/80 cursor-pointer transition-colors",children:[(0,a.jsxs)("td",{className:"py-3 px-4 font-bold text-slate-900",children:[e.name,e.rooms&&a.jsx("span",{className:"text-[10px] text-slate-400 block font-normal",children:e.rooms.map(e=>e.title).join("، ")})]}),(0,a.jsxs)("td",{className:"py-3 px-4 text-slate-600",children:[e.city," ",e.district?`(${e.district})`:""]}),(0,a.jsxs)("td",{className:"py-3 px-4 text-slate-600",children:[a.jsx("span",{className:"font-semibold text-slate-800",children:e.ownerName}),a.jsx("span",{className:"block text-[11px] text-slate-400",children:e.ownerPhone})]}),a.jsx("td",{className:"py-3 px-4",children:a.jsx("span",{className:"bg-slate-100 text-slate-800 px-2 py-0.5 rounded-full font-medium",children:e.stage})}),a.jsx("td",{className:"py-3 px-4",children:(0,a.jsxs)("span",{className:`px-2 py-0.5 rounded-full font-bold text-[10px] ${"گرم"===e.temperature?"bg-rose-100 text-rose-700":"خنثی"===e.temperature?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"}`,children:[e.temperature," (",e.temperatureScore,")"]})}),(0,a.jsxs)("td",{className:"py-3 px-4 text-slate-700",children:[(0,a.jsxs)("span",{className:"font-semibold",children:[e.nextChannel,": "]}),a.jsx("span",{className:"text-slate-500",children:e.nextAction})]}),a.jsx("td",{className:"py-3 px-4 text-slate-600",children:e.nextFollowupAt?(0,a.jsxs)("span",{className:t?"text-rose-600 font-bold":"",children:[new Date(e.nextFollowupAt).toLocaleDateString("fa-IR"),t&&" (تاخیر)"]}):"—"}),a.jsx("td",{className:"py-3 px-4 text-center",children:a.jsx("button",{onClick:s=>j(s,e.id),className:"bg-sky-50 hover:bg-sky-100 text-sky-700 px-2.5 py-1 rounded-lg text-xs font-bold border border-sky-200 transition-colors",children:"مرحله بعد"})})]},e.id)})})]})})})]})}let eh={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};eh.node;let ep=b(eh),eb={name:"send",size:24,node:[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]};eb.node;let eu=b(eb),eg={name:"phone",size:24,node:[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]};eg.node;let ej=b(eg),ef={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};ef.node;let ey=b(ef),eN={name:"lightbulb",size:24,node:[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]};eN.node;let ev=b(eN),ew={welcome_proposal:{title:"ارسال پرپوزال و خوش‌آمدگویی",template:"سلام {owner_name} عزیز، پرپوزال همکاری اختصاصی مجموعه {lead_name} با پلتفرم اکیپا آماده شد. برای افزایش رزرو سانس‌های وسط هفته می‌توانید از لینک زیر مشاهده کنید: https://ekipa.ir/p/{lead_id}\nتیم فروش اکیپا"},pain_solution:{title:"راه‌حل نقطه درد و آفر تست رایگان",template:"سلام {owner_name} گرامی، پیرو صحبت‌مون اکیپا دقیقاً برای پر کردن سانس‌های خالی {lead_name} راه‌اندازی شده است. ۲ هفته اول تست کاملاً رایگان و بدون ریسک است. برای فعال‌سازی کافیست عدد ۱ را ارسال کنید."},case_study:{title:"ارسال آمار موفقیت و کیس‌استادی",template:"سلام {owner_name} عزیز، ماه گذشته اسکیپ‌روم‌های همکار اکیپا میانگین ۳۸ رزرو جدید در سانس‌های کم‌مخاطب ثبت کردند. مشاهده آمار: https://ekipa.ir/stats\nاکیپا - همراه رشد اتاق فرار شما"},loop_nudge:{title:"پیامک دوره‌ای لوپ پیگیری",template:"{owner_name} عزیز سلام، راهنمای جدید اکیپا برای افزایش رزروهای آخر هفته {lead_name} منتشر شد: https://ekipa.ir/blog/tips\nمشتاق همکاری با مجموعه شما هستیم."}};function ek({tasks:e,data:s,onSendSms:t,onAdvanceLead:r,onToggleOnboardingTask:n,onSelectLead:d,onRefresh:i}){let o=s||e||{summary:{totalDueToday:0,overdueCount:0,smsCount:0,callCount:0,onboardingCount:0},smsTasks:[],callTasks:[],onboardingTasks:[]},[c,x]=(0,l.useState)("sms"),[m,h]=(0,l.useState)([]),[p,b]=(0,l.useState)("welcome_proposal"),[u,g]=(0,l.useState)(""),[j,y]=(0,l.useState)(!1),[N,v]=(0,l.useState)({}),w=e=>{m.includes(e)?h(m.filter(s=>s!==e)):h([...m,e])},k=async()=>{if(0!==m.length){y(!0);try{t?await t({leadIds:m,templateKey:p,customMessage:u||void 0}):await fetch("/api/sms/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({leadIds:m,templateKey:p,message:u||void 0})}),h([]),g(""),i()}finally{y(!1)}}},C=async e=>{y(!0);try{t?await t({leadId:e.id,templateKey:p,customMessage:u||void 0}):await fetch("/api/sms/send",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({leadId:e.id,templateKey:p,message:u||void 0})}),i()}finally{y(!1)}},S=async e=>{await r(e)&&i()};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 bg-white p-3 rounded-2xl border border-slate-200 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:()=>x("sms"),className:`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all ${"sms"===c?"bg-indigo-600 text-white shadow-sm":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(U,{className:"w-4 h-4"}),(0,a.jsxs)("span",{children:["پیامک‌های امروز (",(o.smsTasks||[]).length,")"]})]}),(0,a.jsxs)("button",{onClick:()=>x("call"),className:`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all ${"call"===c?"bg-emerald-600 text-white shadow-sm":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(Z,{className:"w-4 h-4"}),(0,a.jsxs)("span",{children:["تماس‌های تلفنی امروز (",(o.callTasks||[]).length,")"]})]}),(0,a.jsxs)("button",{onClick:()=>x("onboarding"),className:`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all ${"onboarding"===c?"bg-amber-600 text-white shadow-sm":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(f,{className:"w-4 h-4"}),(0,a.jsxs)("span",{children:["تسک‌های آنبوردینگ (",(o.onboardingTasks||[]).length,")"]})]})]}),(o.summary?.overdueCount||0)>0&&(0,a.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-rose-700 bg-rose-50 px-3 py-1.5 rounded-lg border border-rose-200",children:[a.jsx(ep,{className:"w-4 h-4"}),(0,a.jsxs)("span",{children:[o.summary.overdueCount," پیگیری معوق و دارای تاخیر"]})]})]}),"sms"===c&&(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,a.jsxs)("div",{className:"lg:col-span-2 bg-white rounded-2xl border border-slate-200 p-6 shadow-sm space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("h3",{className:"text-base font-bold text-slate-900",children:"لیست پیامک‌های زمان‌بندی‌شده"}),a.jsx("p",{className:"text-xs text-slate-500",children:"مجموعه‌هایی که کانال پیگیری امروز آنها پیامک تعیین شده است"})]}),a.jsx("button",{onClick:()=>{m.length===(o.smsTasks||[]).length?h([]):h((o.smsTasks||[]).map(e=>e.id))},className:"text-xs font-semibold text-indigo-600 hover:text-indigo-800",children:m.length===(o.smsTasks||[]).length?"لغو انتخاب همه":"انتخاب همه"})]}),0===(o.smsTasks||[]).length?(0,a.jsxs)("div",{className:"text-center py-10",children:[a.jsx(ee,{className:"w-10 h-10 text-emerald-500 mx-auto mb-2"}),a.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"هیچ پیامکی برای امروز زمان‌بندی نشده است."}),a.jsx("p",{className:"text-xs text-slate-400 mt-1",children:"تمام پیگیری‌های پیامکی به‌موقع انجام شده‌اند."})]}):a.jsx("div",{className:"space-y-3",children:(o.smsTasks||[]).map(e=>{let s=m.includes(e.id);return(0,a.jsxs)("div",{className:`py-3.5 flex items-center justify-between gap-3 text-xs transition-colors rounded-xl px-2.5 ${s?"bg-indigo-50/60":"hover:bg-slate-50"}`,children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"checkbox",checked:s,onChange:()=>w(e.id),className:"w-4 h-4 text-indigo-600 rounded border-slate-300 focus:ring-indigo-500"}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>d(e.id),className:"font-bold text-slate-900 hover:text-indigo-600 text-sm",children:e.name}),a.jsx("span",{className:"text-[11px] bg-slate-100 text-slate-700 px-2 py-0.5 rounded",children:e.city}),e.isOverdue&&a.jsx("span",{className:"text-[10px] font-bold bg-rose-100 text-rose-700 px-1.5 py-0.2 rounded",children:"تاخیر"})]}),(0,a.jsxs)("p",{className:"text-slate-500 mt-0.5",children:["مدیر: ",e.ownerName," (",e.ownerPhone,") • مرحله: ",e.stage]}),(0,a.jsxs)("p",{className:"text-indigo-700 font-medium mt-0.5",children:["اقدام: ",e.nextAction]})]})]}),a.jsx("div",{className:"flex items-center gap-2 shrink-0",children:(0,a.jsxs)("button",{onClick:()=>C(e),disabled:j,className:"flex items-center gap-1 bg-indigo-600 hover:bg-indigo-700 text-white px-3 py-1.5 rounded-lg text-xs font-semibold shadow-sm transition-all",children:[a.jsx(eu,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:"ارسال"})]})})]},e.id)})})]}),(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm space-y-4",children:[a.jsx("h3",{className:"text-base font-bold text-slate-900",children:"ارسال گروهی و تنظیم قالب پیامک"}),(0,a.jsxs)("p",{className:"text-xs text-slate-500",children:[m.length," مخاطب انتخاب شده است."]}),(0,a.jsxs)("div",{className:"space-y-3 text-xs",children:[(0,a.jsxs)("div",{children:[a.jsx("label",{className:"block font-semibold text-slate-700 mb-1",children:"قالب پیامک اکیپا:"}),(0,a.jsxs)("select",{value:p,onChange:e=>b(e.target.value),className:"w-full border border-slate-300 rounded-xl px-3 py-2 text-xs focus:ring-2 focus:ring-indigo-500",children:[a.jsx("option",{value:"welcome_proposal",children:"خوش‌آمدگویی و پرپوزال اختصاصی"}),a.jsx("option",{value:"pain_point_solution",children:"راه‌حل نقطه درد سانس‌های خالی"}),a.jsx("option",{value:"success_stats",children:"آمار موفقیت و افزایش فروش اکیپا"}),a.jsx("option",{value:"loop_weekly",children:"پیگیری دوره‌ای و نکته مارکتینگ"})]})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"block font-semibold text-slate-700 mb-1",children:"پیش‌نمایش متن پیامک:"}),a.jsx("div",{className:"p-3 bg-slate-50 rounded-xl border border-slate-200 text-slate-700 text-xs leading-relaxed whitespace-pre-line",children:"object"==typeof ew[p]?ew[p].template:ew[p]||"متن پیش‌فرض"})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block font-semibold text-slate-700 mb-1",children:["یا متن دلخواه (با متغیرهای ","{lead_name}"," و ","{owner_name}","):"]}),a.jsx("textarea",{value:u,onChange:e=>g(e.target.value),placeholder:"در صورت تمایل متن اختصاصی خود را وارد کنید...",rows:3,className:"w-full border border-slate-300 rounded-xl p-2.5 text-xs focus:ring-2 focus:ring-indigo-500"})]}),(0,a.jsxs)("button",{onClick:k,disabled:j||0===m.length,className:"w-full py-2.5 bg-indigo-600 hover:bg-indigo-700 disabled:bg-slate-300 text-white rounded-xl text-xs font-bold shadow transition-all flex items-center justify-center gap-2",children:[a.jsx(eu,{className:"w-4 h-4"}),(0,a.jsxs)("span",{children:["ارسال گروهی به ",m.length," مجموعه منتخب"]})]})]})]})]}),"call"===c&&(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx("h3",{className:"text-base font-bold text-slate-900",children:"لیست تماس‌های تلفنی امروز"}),a.jsx("p",{className:"text-xs text-slate-500",children:"اتاق‌های فراری که طبق برنامه پیگیری تلفنی دارند همراه با پیشنهاد راه‌حل اعتراض"})]}),0===(o.callTasks||[]).length?(0,a.jsxs)("div",{className:"text-center py-10",children:[a.jsx(ee,{className:"w-10 h-10 text-emerald-500 mx-auto mb-2"}),a.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"هیچ تماس معوقی برای امروز وجود ندارد."})]}):a.jsx("div",{className:"space-y-4",children:(o.callTasks||[]).map(e=>(0,a.jsxs)("div",{className:"p-5 rounded-2xl border border-slate-200 bg-slate-50/50 hover:bg-white hover:border-emerald-300 transition-all space-y-3",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>d(e.id),className:"font-black text-slate-900 hover:text-emerald-700 text-base",children:e.name}),(0,a.jsxs)("span",{className:"text-xs bg-slate-200 text-slate-800 px-2 py-0.5 rounded-full",children:[e.city," ",e.district?`(${e.district})`:""]}),(0,a.jsxs)("span",{className:`text-xs font-bold px-2 py-0.5 rounded-full ${"گرم"===e.temperature?"bg-rose-100 text-rose-700":"خنثی"===e.temperature?"bg-amber-100 text-amber-700":"bg-slate-200 text-slate-700"}`,children:["دمای ",e.temperature," (",e.temperatureScore,")"]}),e.isOverdue&&a.jsx("span",{className:"text-xs font-bold bg-rose-500 text-white px-2 py-0.5 rounded-full",children:"تاخیر در پیگیری"})]}),(0,a.jsxs)("p",{className:"text-xs text-slate-500 mt-1",children:["مدیر مجموعه: ",a.jsx("strong",{children:e.ownerName})," • مرحله: ",a.jsx("strong",{children:e.stage})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("a",{href:`tel:${e.ownerPhone}`,className:"flex items-center gap-1.5 bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-2 rounded-xl text-xs font-bold shadow-sm transition-all",children:[a.jsx(ej,{className:"w-3.5 h-3.5"}),(0,a.jsxs)("span",{children:["تماس (",e.ownerPhone,")"]})]}),(0,a.jsxs)("button",{onClick:()=>S(e.id),className:"flex items-center gap-1.5 bg-sky-600 hover:bg-sky-700 text-white px-3.5 py-2 rounded-xl text-xs font-bold shadow-sm transition-all",children:[a.jsx(ey,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:"ثبت تماس و مرحله بعد"})]})]})]}),e.suggestedResponse&&(0,a.jsxs)("div",{className:"bg-amber-50/80 border border-amber-200 rounded-xl p-3 text-xs space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 font-bold text-amber-900",children:[a.jsx(ev,{className:"w-4 h-4 text-amber-600"}),(0,a.jsxs)("span",{children:['پاسخ پیشنهادی اکیپا به اعتراض: "',e.objection,'"']})]}),a.jsx("p",{className:"text-amber-800 leading-relaxed",children:e.suggestedResponse}),e.suggestedKeyPoint&&(0,a.jsxs)("p",{className:"text-[11px] text-amber-700 font-semibold",children:["نکته کلیدی: ",e.suggestedKeyPoint]})]}),(0,a.jsxs)("div",{className:"text-xs text-slate-600 bg-white p-2.5 rounded-xl border border-slate-100 flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("span",{className:"font-semibold text-slate-700",children:"اقدام مقرر: "}),a.jsx("span",{children:e.nextAction})]}),a.jsx("button",{onClick:()=>d(e.id),className:"text-sky-600 font-bold hover:underline",children:"مشاهده شناسنامه و ثبت جزئیات"})]})]},e.id))})]}),"onboarding"===c&&(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 shadow-sm space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx("h3",{className:"text-base font-bold text-slate-900",children:"چک‌لیست آنبوردینگ مجموعه‌های تازه جذب‌شده"}),a.jsx("p",{className:"text-xs text-slate-500",children:"تسک‌های ۴ هفته ابتدایی برای تضمین اولین فروش و اتصال به تقویم اکیپا"})]}),0===(o.onboardingTasks||[]).length?(0,a.jsxs)("div",{className:"text-center py-10",children:[a.jsx(ee,{className:"w-10 h-10 text-emerald-500 mx-auto mb-2"}),a.jsx("p",{className:"text-sm font-semibold text-slate-700",children:"هیچ تسک آنبوردینگ معوقی وجود ندارد."})]}):a.jsx("div",{className:"divide-y divide-slate-100",children:(o.onboardingTasks||[]).map(e=>(0,a.jsxs)("div",{className:"py-3 flex items-center justify-between gap-3 text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("input",{type:"checkbox",checked:!!e.doneAt,onChange:s=>{let t=s.target.checked;n?n(e.leadId,e.id,t).then(i):fetch(`/api/leads/${e.leadId}/onboarding`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.id,done:t})}).then(i)},className:"w-4 h-4 text-emerald-600 rounded border-slate-300 focus:ring-emerald-500"}),(0,a.jsxs)("div",{children:[a.jsx("p",{className:"font-bold text-slate-900 text-sm",children:e.title}),(0,a.jsxs)("p",{className:"text-slate-500 mt-0.5",children:["مجموعه:"," ",a.jsx("button",{onClick:()=>d(e.leadId),className:"text-sky-700 font-bold hover:underline",children:e.lead.name})," ","• هفته ",e.week," • مدیر: ",e.lead.ownerName," (",e.lead.ownerPhone,")"]})]})]}),(0,a.jsxs)("span",{className:"text-[11px] font-semibold bg-amber-100 text-amber-800 px-2 py-0.5 rounded-full",children:["هفته ",e.week]})]},e.id))})]})]})}let eC={name:"clock",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]};eC.node;let eS=b(eC);function eM({leads:e,onRefresh:s,onSelectLead:t}){let[r,n]=(0,l.useState)(null),[d,i]=(0,l.useState)("all"),o=e.filter(e=>"بسته شد / موفق"===e.stage||e.onboardingTasks&&e.onboardingTasks.length>0),c=o.filter(e=>"graduated"===d?e.clubMember:"in_progress"!==d||!e.clubMember),x=async(e,t,a)=>{n(t);try{(await fetch(`/api/leads/${e}/onboarding`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:t,completed:!a})})).ok&&s()}catch(e){console.error(e)}finally{n(null)}},m=async(e,t)=>{try{(await fetch(`/api/leads/${e}/onboarding`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({clubMember:!t})})).ok&&s()}catch(e){console.error(e)}};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-gradient-to-r from-emerald-600 to-teal-700 rounded-2xl p-6 text-white shadow-lg flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(w,{className:"w-7 h-7 text-emerald-200"}),a.jsx("h2",{className:"text-xl font-bold",children:"فرآیند ۴ هفته‌ای آنبوردینگ اکیپا"})]}),a.jsx("p",{className:"text-emerald-100 text-sm max-w-2xl leading-relaxed",children:"مجموعه‌هایی که به عنوان شریک جذب شده‌اند وارد دوره ۴ هفته‌ای استقرار می‌شوند. تکمیل تمام وظایف این ۴ هفته موجب ارتقای مجموعه به سطح \xabعضو باشگاه اکیپا\xbb و آغاز دوره‌های تمدید وفاداری می‌شود."})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"bg-white/10 backdrop-blur-md px-4 py-2 rounded-xl text-center border border-white/20",children:[a.jsx("span",{className:"text-xs text-emerald-200 block",children:"در حال آنبوردینگ"}),a.jsx("span",{className:"text-2xl font-bold",children:o.filter(e=>!e.clubMember).length})]}),(0,a.jsxs)("div",{className:"bg-white/10 backdrop-blur-md px-4 py-2 rounded-xl text-center border border-white/20",children:[a.jsx("span",{className:"text-xs text-emerald-200 block",children:"اعضای باشگاه اکیپا"}),a.jsx("span",{className:"text-2xl font-bold",children:o.filter(e=>e.clubMember).length})]})]})]}),a.jsx("div",{className:"flex items-center justify-between bg-white p-2 rounded-xl border border-slate-200",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("button",{onClick:()=>i("all"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${"all"===d?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:["همه مجموعه‌ها (",o.length,")"]}),(0,a.jsxs)("button",{onClick:()=>i("in_progress"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${"in_progress"===d?"bg-emerald-600 text-white":"text-slate-600 hover:bg-slate-100"}`,children:["در حال استقرار (",o.filter(e=>!e.clubMember).length,")"]}),(0,a.jsxs)("button",{onClick:()=>i("graduated"),className:`px-4 py-2 rounded-lg text-sm font-medium transition-colors ${"graduated"===d?"bg-amber-600 text-white":"text-slate-600 hover:bg-slate-100"}`,children:["اعضای باشگاه اکیپا (",o.filter(e=>e.clubMember).length,")"]})]})}),0===c.length?(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-12 text-center text-slate-500",children:[a.jsx(w,{className:"w-12 h-12 text-slate-300 mx-auto mb-3"}),a.jsx("p",{className:"font-medium text-slate-700",children:"هیچ مجموعه‌ای در این بخش یافت نشد."}),a.jsx("p",{className:"text-sm text-slate-400 mt-1",children:"با بستن موفق معامله‌ها در پایپ‌لاین، مجموعه‌ها به طور خودکار به این بخش منتقل می‌شوند."})]}):a.jsx("div",{className:"grid grid-cols-1 gap-6",children:c.map(e=>{let s=e.onboardingTasks||[],l=s.filter(e=>e.completed).length,n=s.length||6,d=n>0?Math.round(l/n*100):0;return(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 overflow-hidden shadow-sm hover:shadow-md transition-shadow",children:[(0,a.jsxs)("div",{className:"p-5 border-b border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-4 bg-slate-50/50",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl bg-emerald-100 text-emerald-700 font-bold flex items-center justify-center text-lg",children:e.name.substring(0,2)}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>t(e),className:"font-bold text-slate-900 hover:text-emerald-700 text-lg transition-colors",children:e.name}),e.clubMember&&(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-amber-100 text-amber-800 border border-amber-300",children:[a.jsx(H,{className:"w-3.5 h-3.5 text-amber-600"}),"عضو باشگاه اکیپا"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 text-xs text-slate-500 mt-1",children:[(0,a.jsxs)("span",{children:[e.city," ",e.district?`(${e.district})`:""]}),a.jsx("span",{children:"•"}),(0,a.jsxs)("span",{children:["مدیر: ",e.managerName||"نامشخص"]}),a.jsx("span",{children:"•"}),a.jsx("span",{dir:"ltr",children:e.phone})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("div",{className:"w-44 text-left",children:[(0,a.jsxs)("div",{className:"flex justify-between text-xs text-slate-500 mb-1",children:[a.jsx("span",{children:"پیشرفت استقرار"}),(0,a.jsxs)("span",{className:"font-semibold text-slate-800",children:[d,"%"]})]}),a.jsx("div",{className:"w-full bg-slate-200 h-2 rounded-full overflow-hidden",children:a.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${100===d?"bg-emerald-500":"bg-teal-500"}`,style:{width:`${d}%`}})})]}),a.jsx("button",{onClick:()=>m(e.id,e.clubMember),className:`px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${e.clubMember?"border-amber-300 bg-amber-50 text-amber-800 hover:bg-amber-100":"border-slate-300 bg-white text-slate-700 hover:bg-slate-50"}`,children:e.clubMember?"خروج از باشگاه":"ارتقا به باشگاه اکیپا"})]})]}),a.jsx("div",{className:"p-5 grid grid-cols-1 md:grid-cols-4 gap-4",children:[1,2,3,4].map(t=>{let l=s.filter(e=>e.week===t),n=l.length>0&&l.every(e=>e.completed);return(0,a.jsxs)("div",{className:`rounded-xl p-3 border ${n?"bg-emerald-50/60 border-emerald-200":e.onboardingWeek===t?"bg-amber-50/60 border-amber-300 ring-2 ring-amber-400/20":"bg-slate-50/60 border-slate-200"}`,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-xs font-bold text-slate-800",children:1===t?"هفته ۱: راه‌اندازی و پروفایل":2===t?"هفته ۲: سانس‌های آزمایشی":3===t?"هفته ۳: اولین کمپین جذب":"هفته ۴: تثبیت و ارزیابی"}),n?a.jsx(ee,{className:"w-4 h-4 text-emerald-600"}):e.onboardingWeek===t?a.jsx("span",{className:"text-[10px] bg-amber-200 text-amber-800 px-1.5 py-0.5 rounded font-medium",children:"جاری"}):a.jsx(eS,{className:"w-3.5 h-3.5 text-slate-400"})]}),a.jsx("div",{className:"space-y-1.5",children:0===l.length?a.jsx("p",{className:"text-xs text-slate-400 italic",children:"بدون وظیفه تعریف‌شده"}):l.map(s=>(0,a.jsxs)("button",{disabled:r===s.id,onClick:()=>x(e.id,s.id,s.completed),className:`w-full text-right p-2 rounded-lg text-xs flex items-start gap-2 transition-all ${s.completed?"bg-emerald-100/70 text-emerald-900 line-through opacity-80":"bg-white border border-slate-200 text-slate-700 hover:border-emerald-400 hover:bg-emerald-50/30"}`,children:[a.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center mt-0.5 shrink-0 ${s.completed?"bg-emerald-600 border-emerald-600 text-white":"border-slate-300 bg-white"}`,children:s.completed&&a.jsx(ey,{className:"w-3 h-3 stroke-[3]"})}),a.jsx("span",{className:"leading-tight",children:s.title})]},s.id))})]},t)})})]},e.id)})})]})}let ez={name:"workflow",size:24,node:[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]};ez.node;let e$=b(ez),eT={name:"book-open",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z",key:"1fyvmf"}]]};eT.node;let eP=b(eT),eA={name:"database",size:24,node:[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]};eA.node;let e_=b(eA),eL={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]};eL.node;let eD=b(eL),eO={name:"hard-drive",size:24,node:[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]]};eO.node;let eR=b(eO),eI={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};eI.node;let eq=b(eI);function eH({leadCount:e,stats:s,onRefresh:t}){let[r,n]=(0,l.useState)("automation"),[d,i]=(0,l.useState)(""),[o,c]=(0,l.useState)("mock"),[x,m]=(0,l.useState)(!1);return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(C,{className:"w-6 h-6 text-slate-700"}),a.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"تنظیمات و زیرساخت اتوماسیون"})]}),a.jsx("p",{className:"text-sm text-slate-500",children:"پیکربندی قوانین خودکار پایپ‌لاین، موتور پیامک، کتابچه اعتراضات و دیتابیس محلی پایدار SQLite"})]}),x&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-emerald-700 bg-emerald-50 px-4 py-2 rounded-xl border border-emerald-200 text-sm",children:[a.jsx(ee,{className:"w-4 h-4"}),a.jsx("span",{children:"تنظیمات با موفقیت ذخیره شد"})]})]}),(0,a.jsxs)("div",{className:"flex gap-2 border-b border-slate-200 pb-2",children:[(0,a.jsxs)("button",{onClick:()=>n("automation"),className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-medium transition-colors ${"automation"===r?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(e$,{className:"w-4 h-4"}),"قوانین مراحل و تاخیرها"]}),(0,a.jsxs)("button",{onClick:()=>n("objections"),className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-medium transition-colors ${"objections"===r?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(eP,{className:"w-4 h-4"}),"کتابچه پاسخ به اعتراضات"]}),(0,a.jsxs)("button",{onClick:()=>n("sms"),className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-medium transition-colors ${"sms"===r?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(U,{className:"w-4 h-4"}),"قالب‌های پیامک و اتصال n8n"]}),(0,a.jsxs)("button",{onClick:()=>n("database"),className:`flex items-center gap-2 px-4 py-2.5 rounded-xl text-sm font-medium transition-colors ${"database"===r?"bg-slate-900 text-white":"text-slate-600 hover:bg-slate-100"}`,children:[a.jsx(e_,{className:"w-4 h-4"}),"پایگاه داده محلی SQLite"]})]}),"automation"===r&&(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 overflow-hidden",children:[(0,a.jsxs)("div",{className:"p-5 border-b border-slate-100 bg-slate-50 flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[a.jsx("h3",{className:"font-bold text-slate-800",children:"جدول قوانین اتوماسیون پایپ‌لاین"}),a.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"سیستم با ثبت هر اقدام، مرحله بعدی، کانال ارتباطی و فاصله زمانی مناسب را بر اساس این ماتریس محاسبه می‌کند."})]}),a.jsx("span",{className:"text-xs font-semibold px-2.5 py-1 bg-teal-100 text-teal-800 rounded-lg",children:"۱۰ مرحله استاندارد"})]}),a.jsx("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full text-right text-xs",children:[a.jsx("thead",{className:"bg-slate-100/70 text-slate-600 font-semibold border-b border-slate-200",children:(0,a.jsxs)("tr",{children:[a.jsx("th",{className:"p-3.5",children:"مرحله"}),a.jsx("th",{className:"p-3.5",children:"اقدام بعدی خودکار"}),a.jsx("th",{className:"p-3.5",children:"کانال پیگیری"}),a.jsx("th",{className:"p-3.5",children:"فاصله زمانی (روز)"}),a.jsx("th",{className:"p-3.5",children:"برچسب پیامک پیش‌فرض"})]})}),a.jsx("tbody",{className:"divide-y divide-slate-100",children:ei.map((e,s)=>(0,a.jsxs)("tr",{className:"hover:bg-slate-50/50",children:[a.jsx("td",{className:"p-3.5 font-bold text-slate-900",children:e.currentStage}),a.jsx("td",{className:"p-3.5 text-slate-700",children:e.action}),a.jsx("td",{className:"p-3.5",children:a.jsx("span",{className:`px-2 py-0.5 rounded-full text-[11px] font-semibold ${"پیامک"===e.channel?"bg-blue-100 text-blue-800":"bg-emerald-100 text-emerald-800"}`,children:e.channel})}),a.jsx("td",{className:"p-3.5 text-slate-800 font-mono",children:0===e.delayDays?"همان روز":`${e.delayDays} روز`}),a.jsx("td",{className:"p-3.5",children:e.smsTag?a.jsx("span",{className:"px-2 py-0.5 rounded bg-slate-100 text-slate-700 font-mono text-[11px]",children:e.smsTag}):a.jsx("span",{className:"text-slate-400",children:"—"})})]},s))})]})})]}),"objections"===r&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-2xl p-5 text-amber-900 flex items-start gap-3",children:[a.jsx(G,{className:"w-5 h-5 text-amber-600 shrink-0 mt-0.5"}),(0,a.jsxs)("div",{children:[a.jsx("h4",{className:"font-bold text-sm",children:"پلی‌بوک پاسخ به اعتراضات صاحبان اتاق فرار"}),a.jsx("p",{className:"text-xs text-amber-800 mt-1 leading-relaxed",children:"این راهنما در تماس‌های تلفنی و ثبت لاگ فعالیت برای هر لید به عنوان دستیار هوشمند نمایش داده می‌شود تا تیم فروش سریع‌ترین و بهترین پاسخ اقناعی را ارائه دهد."})]})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Object.entries(ec).map(([e,s],t)=>(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-5 shadow-sm space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"font-bold text-sm text-slate-900 bg-slate-100 px-3 py-1 rounded-xl",children:e}),a.jsx("span",{className:"text-xs text-rose-600 bg-rose-50 px-2 py-0.5 rounded-md font-medium",children:"اعتراض متداول"})]}),(0,a.jsxs)("div",{children:[a.jsx("span",{className:"text-[11px] font-bold text-slate-500 block mb-1",children:"زاویه دید مشتری:"}),(0,a.jsxs)("p",{className:"text-xs text-slate-600 bg-slate-50 p-2.5 rounded-xl border border-slate-100 leading-relaxed",children:["\xab",s.objection||s.angle,"\xbb"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-[11px] font-bold text-emerald-700 block mb-1 flex items-center gap-1",children:[a.jsx(F,{className:"w-3.5 h-3.5"}),"پاسخ پیشنهادی اکیپا:"]}),a.jsx("p",{className:"text-xs text-emerald-900 bg-emerald-50/80 p-3 rounded-xl border border-emerald-200 leading-relaxed font-medium",children:s.rebuttal||s.pitch})]})]},t))})]}),"sms"===r&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 space-y-4",children:[(0,a.jsxs)("h3",{className:"font-bold text-slate-900 flex items-center gap-2",children:[a.jsx(U,{className:"w-5 h-5 text-indigo-600"}),"تنظیمات وب‌هوک n8n و شبیه‌ساز پیامک"]}),a.jsx("p",{className:"text-xs text-slate-500",children:"در حال حاضر سامانه پیامک در وضعیت خودکفا (Mock) عمل می‌کند و کلیه رویدادهای ارسالی در جدول تاریخچه دیتابیس ثبت می‌شوند. در صورت اتصال وب‌هوک n8n، پیامک‌ها به سرویس کاوه‌نگار یا فراز انتقال می‌یابند."}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-2",children:[(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1.5",children:"حالت ارسال پیامک"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>c("mock"),className:`flex-1 py-2 px-3 rounded-xl text-xs font-semibold border transition-colors ${"mock"===o?"bg-emerald-600 text-white border-emerald-600":"bg-white text-slate-600 border-slate-300"}`,children:"شبیه‌ساز داخلی (Mock / بدون وابستگی)"}),a.jsx("button",{onClick:()=>c("live"),className:`flex-1 py-2 px-3 rounded-xl text-xs font-semibold border transition-colors ${"live"===o?"bg-indigo-600 text-white border-indigo-600":"bg-white text-slate-600 border-slate-300"}`,children:"اتصال زنده به n8n Webhook"})]})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1.5",children:"آدرس وب‌هوک n8n (اختیاری)"}),a.jsx("input",{type:"text",placeholder:"https://n8n.domain.com/webhook/crm-sms",value:d,onChange:e=>i(e.target.value),dir:"ltr",className:"w-full text-xs font-mono px-3 py-2 rounded-xl border border-slate-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"})]})]}),a.jsx("div",{className:"pt-2 flex justify-end",children:(0,a.jsxs)("button",{onClick:()=>{m(!0),setTimeout(()=>m(!1),3e3)},className:"flex items-center gap-1.5 px-4 py-2 bg-slate-900 text-white text-xs font-semibold rounded-xl hover:bg-slate-800 transition-colors",children:[a.jsx(eD,{className:"w-3.5 h-3.5"}),"ذخیره تنظیمات وب‌هوک"]})})]}),(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 space-y-4",children:[a.jsx("h3",{className:"font-bold text-slate-900",children:"قالب‌های فعال پیامک اکیپا"}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Object.entries(ew).map(([e,s])=>(0,a.jsxs)("div",{className:"border border-slate-200 rounded-xl p-4 bg-slate-50/50 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"font-mono text-xs font-bold bg-indigo-50 text-indigo-700 px-2 py-0.5 rounded",children:e}),a.jsx("span",{className:"text-[11px] text-slate-400",children:"قالب خودکار"})]}),a.jsx("p",{className:"text-xs text-slate-700 leading-relaxed font-mono whitespace-pre-line bg-white p-2.5 rounded-lg border border-slate-100",children:"string"==typeof s?s:s.template})]},e))})]})]}),"database"===r&&(0,a.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-6 space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-12 h-12 rounded-2xl bg-indigo-50 flex items-center justify-center text-indigo-600",children:a.jsx(eR,{className:"w-6 h-6"})}),(0,a.jsxs)("div",{children:[a.jsx("h3",{className:"font-bold text-slate-900 text-base",children:"پایگاه داده محلی SQLite (مستقل و پایدار)"}),a.jsx("p",{className:"text-xs text-slate-500",children:"تمام اطلاعات، اتاق‌ها، فعالیت‌ها و وظایف آنبوردینگ در دیسک محلی ذخیره می‌شوند."})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-200",children:[a.jsx("span",{className:"text-xs text-slate-500 block mb-1",children:"مسیر فایل دیتابیس"}),a.jsx("span",{className:"font-mono text-xs font-bold text-slate-800 break-all",dir:"ltr",children:"/workspace/personal/crm/prisma/crm.db"})]}),(0,a.jsxs)("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-200",children:[a.jsx("span",{className:"text-xs text-slate-500 block mb-1",children:"تعداد لیدهای فعال"}),(0,a.jsxs)("span",{className:"text-xl font-bold text-slate-800",children:[e," مجموعه"]})]}),(0,a.jsxs)("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-200",children:[a.jsx("span",{className:"text-xs text-slate-500 block mb-1",children:"سیستم نگهداری و ORM"}),a.jsx("span",{className:"text-sm font-bold text-emerald-700",children:"Prisma Client v5.22 (بدون نیاز به شبکه)"})]})]}),(0,a.jsxs)("div",{className:"border-t border-slate-100 pt-4 flex items-center justify-between text-xs text-slate-500",children:[(0,a.jsxs)("span",{children:["برای پشتیبان‌گیری، کپی کردن فایل ",a.jsx("code",{className:"font-mono bg-slate-100 px-1 py-0.5 rounded",children:"crm.db"})," یا گرفتن خروجی اکسل از نوار بالا کافی است."]}),(0,a.jsxs)("button",{onClick:t,className:"flex items-center gap-1 text-slate-700 hover:text-slate-900 font-semibold",children:[a.jsx(eq,{className:"w-3.5 h-3.5"}),"بروزرسانی وضعیت دیتابیس"]})]})]})]})}let eE={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};eE.node;let eF=b(eE),eV={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};eV.node;let eW=b(eV),eJ={name:"building-complex",size:24,node:[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],aliases:["building-2"]};eJ.node;let eB=b(eJ),eK={name:"rotate-ccw-clock",size:24,node:[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],aliases:["history"]};eK.node;let eG=b(eK),eQ={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};eQ.node;let eU=b(eQ);function eX({lead:e,isOpen:s,onClose:t,onRefresh:r}){if(!s||!e)return null;let[n,d]=(0,l.useState)("info"),[i,o]=(0,l.useState)({...e}),[c,x]=(0,l.useState)(!1),[m,h]=(0,l.useState)(!1),[p,b]=(0,l.useState)(""),[u,g]=(0,l.useState)(!1),[j,f]=(0,l.useState)(""),[y,N]=(0,l.useState)(""),[v,w]=(0,l.useState)(6),[k,C]=(0,l.useState)(25e4),[S,M]=(0,l.useState)("تماس تلفنی"),[z,$]=(0,l.useState)(""),[T,A]=(0,l.useState)(!1),_=async()=>{x(!0);try{let s={...i,ownerName:i.ownerName||i.managerName,ownerPhone:i.ownerPhone||i.phone,nextAction:i.nextAction||i.nextActionNote,nextChannel:i.nextChannel||i.nextFollowupChannel,painPoint:i.painPoint||i.biggestPain,aspiration:i.aspiration||i.coreDesire,ekipaHook:i.ekipaHook||i.hookForEkipa};(await fetch(`/api/leads/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok&&(r(),alert("اطلاعات با موفقیت ذخیره شد."))}catch(e){console.error(e)}finally{x(!1)}},L=async()=>{h(!0);try{(await fetch(`/api/leads/${e.id}/advance`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notes:"ارتقای مرحله از پروفایل لید"})})).ok&&(r(),t())}catch(e){console.error(e)}finally{h(!1)}},D=async()=>{if(!p.trim()){alert("لطفاً ابتدا یادداشت مکالمه را وارد کنید.");return}g(!0),f("");try{let s=await fetch("/api/ai/extract",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({leadId:e.id,text:p})}),t=await s.json();if(t.success&&t.extracted){let e=t.extracted;o(s=>({...s,salesChannels:e.salesChannels?e.salesChannels.join(", "):s.salesChannels,deadSlots:e.deadSlots||s.deadSlots,biggestPain:e.biggestPain||s.biggestPain,coreDesire:e.coreDesire||s.coreDesire,hookForEkipa:e.hookForEkipa||s.hookForEkipa,objectionStatus:e.objectionStatus||s.objectionStatus,smsTag:e.suggestedSmsTag||s.smsTag})),f("اطلاعات با هوش مصنوعی استخراج و فرم بروزرسانی شد.")}}catch(e){console.error(e)}finally{g(!1)}},R=async s=>{if(s.preventDefault(),z.trim()){A(!0);try{(await fetch(`/api/leads/${e.id}/activities`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:S,notes:z})})).ok&&($(""),r())}catch(e){console.error(e)}finally{A(!1)}}},I=e=>{let s=i.rooms||[];o({...i,rooms:s.filter((s,t)=>t!==e)})};return a.jsx("div",{className:"fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-3 md:p-6 overflow-y-auto",children:(0,a.jsxs)("div",{className:"bg-white rounded-3xl shadow-2xl border border-slate-200 w-full max-w-4xl max-h-[90vh] flex flex-col overflow-hidden animate-in fade-in zoom-in-95 duration-150",children:[(0,a.jsxs)("div",{className:"p-6 border-b border-slate-200 flex flex-col md:flex-row md:items-center justify-between gap-4 bg-slate-50",children:[(0,a.jsxs)("div",{className:"flex items-start gap-4",children:[a.jsx("div",{className:"w-14 h-14 rounded-2xl bg-teal-600 text-white font-bold text-xl flex items-center justify-center shrink-0 shadow-md",children:e.name.substring(0,2)}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-xl font-bold text-slate-900",children:e.name}),(0,a.jsxs)("span",{className:`px-3 py-0.5 rounded-full text-xs font-bold border ${"گرم"===e.temperature?"bg-rose-50 text-rose-700 border-rose-200":"خنثی"===e.temperature?"bg-amber-50 text-amber-700 border-amber-200":"bg-blue-50 text-blue-700 border-blue-200"}`,children:[a.jsx(O,{className:"w-3.5 h-3.5 inline ml-1"}),e.temperature," (",e.temperatureScore," امتیاز)"]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 text-xs text-slate-500 mt-1",children:[(0,a.jsxs)("span",{children:[e.city," ",e.district?`(${e.district})`:""]}),a.jsx("span",{children:"•"}),a.jsx("span",{className:"font-semibold text-slate-700",children:e.stage}),a.jsx("span",{children:"•"}),a.jsx("span",{dir:"ltr",children:e.phone})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)("button",{onClick:L,disabled:m,className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl bg-teal-600 hover:bg-teal-700 text-white text-xs font-bold shadow-md transition-all active:scale-95",children:[a.jsx(eF,{className:"w-4 h-4"}),a.jsx("span",{children:"انجام شد، برو مرحله‌ی بعد"})]}),a.jsx("button",{onClick:t,className:"p-2.5 rounded-xl text-slate-400 hover:text-slate-700 hover:bg-slate-200/60 transition-colors",children:a.jsx(eW,{className:"w-5 h-5"})})]})]}),(0,a.jsxs)("div",{className:"flex border-b border-slate-200 px-6 gap-6 bg-white text-sm font-semibold",children:[(0,a.jsxs)("button",{onClick:()=>d("info"),className:`py-3.5 border-b-2 transition-colors flex items-center gap-2 ${"info"===n?"border-teal-600 text-teal-700":"border-transparent text-slate-500 hover:text-slate-800"}`,children:[a.jsx(eB,{className:"w-4 h-4"}),"مشخصات، پایپ‌لاین و اتاق‌ها"]}),(0,a.jsxs)("button",{onClick:()=>d("ai"),className:`py-3.5 border-b-2 transition-colors flex items-center gap-2 ${"ai"===n?"border-teal-600 text-teal-700":"border-transparent text-slate-500 hover:text-slate-800"}`,children:[a.jsx(F,{className:"w-4 h-4 text-purple-600"}),"تحلیل هوشمند و پر کردن با AI"]}),(0,a.jsxs)("button",{onClick:()=>d("activities"),className:`py-3.5 border-b-2 transition-colors flex items-center gap-2 ${"activities"===n?"border-teal-600 text-teal-700":"border-transparent text-slate-500 hover:text-slate-800"}`,children:[a.jsx(eG,{className:"w-4 h-4"}),"تاریخچه تعاملات (",e.activities?.length||0,")"]})]}),(0,a.jsxs)("div",{className:"p-6 overflow-y-auto space-y-6 flex-1 bg-slate-50/30",children:["info"===n&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-white p-5 rounded-2xl border border-slate-200 shadow-sm space-y-4",children:[a.jsx("h3",{className:"font-bold text-sm text-slate-900 border-b border-slate-100 pb-2",children:"اطلاعات تماس و مدیریت"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"نام مدیر"}),a.jsx("input",{type:"text",value:i.managerName||"",onChange:e=>o({...i,managerName:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"شماره تماس"}),a.jsx("input",{type:"text",dir:"ltr",value:i.phone||"",onChange:e=>o({...i,phone:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"شهر"}),a.jsx("input",{type:"text",value:i.city||"",onChange:e=>o({...i,city:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"منطقه / محله"}),a.jsx("input",{type:"text",value:i.district||"",onChange:e=>o({...i,district:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"آیدی اینستاگرام"}),a.jsx("input",{type:"text",dir:"ltr",value:i.instagram||"",onChange:e=>o({...i,instagram:e.target.value}),placeholder:"@escaperoom",className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"وب‌سایت / پلتفرم رزرو"}),a.jsx("input",{type:"text",dir:"ltr",value:i.website||"",onChange:e=>o({...i,website:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]})]})]}),(0,a.jsxs)("div",{className:"bg-white p-5 rounded-2xl border border-slate-200 shadow-sm space-y-4",children:[a.jsx("h3",{className:"font-bold text-sm text-slate-900 border-b border-slate-100 pb-2",children:"وضعیت پایپ‌لاین و پیگیری"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"مرحله فعلی"}),a.jsx("select",{value:i.stage||"",onChange:e=>o({...i,stage:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 font-semibold",children:eo.map((e,s)=>a.jsx("option",{value:e.stage,children:e.stage},s))})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"کانال پیگیری بعدی"}),(0,a.jsxs)("select",{value:i.nextFollowupChannel||"تلفنی",onChange:e=>o({...i,nextFollowupChannel:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500",children:[a.jsx("option",{value:"تلفنی",children:"تلفنی"}),a.jsx("option",{value:"پیامک",children:"پیامک"}),a.jsx("option",{value:"حضوری",children:"حضوری"}),a.jsx("option",{value:"انجام شد",children:"انجام شد"})]})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"دور لوپ پیگیری"}),a.jsx("input",{type:"number",value:i.loopIndex||0,onChange:e=>o({...i,loopIndex:Number(e.target.value)}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{className:"md:col-span-3",children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"اقدام بعدی یا خلاصه یادداشت"}),a.jsx("input",{type:"text",value:i.nextActionNote||"",onChange:e=>o({...i,nextActionNote:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]})]})]}),(0,a.jsxs)("div",{className:"bg-white p-5 rounded-2xl border border-slate-200 shadow-sm space-y-4",children:[(0,a.jsxs)("h3",{className:"font-bold text-sm text-slate-900 border-b border-slate-100 pb-2",children:["اتاق‌های فرار مجموعه (",i.rooms?.length||0," اتاق)"]}),a.jsx("div",{className:"space-y-2",children:(i.rooms||[]).map((e,s)=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-xl bg-slate-50 border border-slate-200 text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"w-6 h-6 rounded-lg bg-teal-100 text-teal-800 font-bold flex items-center justify-center",children:s+1}),a.jsx("span",{className:"font-bold text-slate-800 text-sm",children:e.name}),(0,a.jsxs)("span",{className:"text-slate-500",children:["ظرفیت: ",e.capacity||6," نفر"]}),(0,a.jsxs)("span",{className:"text-slate-500",children:["قیمت هر نفر: ",(e.pricePerPerson||25e4).toLocaleString("fa-IR")," تومان"]})]}),a.jsx("button",{onClick:()=>I(s),className:"text-rose-500 hover:text-rose-700 p-1 rounded-lg",children:a.jsx(eU,{className:"w-4 h-4"})})]},s))}),(0,a.jsxs)("div",{className:"pt-2 border-t border-slate-100 flex flex-wrap items-center gap-2",children:[a.jsx("input",{type:"text",placeholder:"نام اتاق فرار جدید",value:y,onChange:e=>N(e.target.value),className:"text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 flex-1"}),a.jsx("input",{type:"number",placeholder:"ظرفیت",value:v,onChange:e=>w(Number(e.target.value)),className:"text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 w-20"}),a.jsx("input",{type:"number",placeholder:"قیمت هر نفر",value:k,onChange:e=>C(Number(e.target.value)),className:"text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 w-32"}),(0,a.jsxs)("button",{onClick:()=>{if(!y.trim())return;let e=i.rooms||[];o({...i,rooms:[...e,{name:y.trim(),capacity:Number(v)||6,pricePerPerson:Number(k)||25e4}]}),N("")},className:"flex items-center gap-1 px-3 py-2 bg-slate-800 hover:bg-slate-900 text-white rounded-xl text-xs font-semibold",children:[a.jsx(P,{className:"w-4 h-4"}),"افزودن اتاق"]})]})]}),a.jsx("div",{className:"flex justify-end",children:(0,a.jsxs)("button",{onClick:_,disabled:c,className:"flex items-center gap-2 px-6 py-2.5 bg-teal-600 hover:bg-teal-700 text-white rounded-xl text-xs font-bold shadow transition-all",children:[a.jsx(eD,{className:"w-4 h-4"}),a.jsx("span",{children:c?"در حال ذخیره...":"ذخیره تغییرات"})]})})]}),"ai"===n&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-purple-50/70 border border-purple-200 rounded-2xl p-5 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-purple-900 font-bold text-sm",children:[a.jsx(F,{className:"w-5 h-5 text-purple-600"}),a.jsx("span",{children:"استخراج خودکار اطلاعات لید از متن تماس (AI)"})]}),a.jsx("p",{className:"text-xs text-purple-800 leading-relaxed",children:"متن خلاصه مکالمه یا یادداشت صوتی تبدیل‌شده به متن را در کادر زیر وارد کنید و دکمه را بزنید؛ سیستم هوشمند فیلدهای سانس‌های خالی، خواست قلبی، چالش‌ها و اعتراض مشتری را خودکار استخراج می‌کند."}),a.jsx("textarea",{rows:3,value:p,onChange:e=>b(e.target.value),placeholder:"مثال: با آقای باقری صحبت شد. گفتن وسط هفته‌ها سانس‌های ۲ تا ۶ بعدازظهر کاملاً خالیه. از کارمزد پلتفرم‌های دیگه ناراضین و دنبال فروش بیشتر آخر هفته نیستن بلکه وسط هفته براشون مهمه...",className:"w-full text-xs p-3 rounded-xl border border-purple-300 focus:ring-2 focus:ring-purple-500 bg-white"}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("button",{onClick:D,disabled:u,className:"flex items-center gap-2 px-5 py-2.5 bg-purple-600 hover:bg-purple-700 text-white text-xs font-bold rounded-xl shadow-md transition-all active:scale-95",children:[a.jsx(F,{className:"w-4 h-4"}),a.jsx("span",{children:u?"در حال پردازش هوش مصنوعی...":"✨ پر کردن خودکار با AI"})]}),j&&a.jsx("span",{className:"text-xs text-emerald-700 font-bold bg-emerald-100 px-3 py-1 rounded-lg",children:j})]})]}),(0,a.jsxs)("div",{className:"bg-white p-5 rounded-2xl border border-slate-200 space-y-4",children:[a.jsx("h3",{className:"font-bold text-sm text-slate-900 border-b border-slate-100 pb-2",children:"بینش‌های استخراج‌شده و قلاب اکیپا"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"سانس‌های مرده و خالی"}),a.jsx("input",{type:"text",value:i.deadSlots||"",onChange:e=>o({...i,deadSlots:e.target.value}),placeholder:"مثال: شنبه تا سه‌شنبه ۱۲ تا ۱۸",className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"کانال‌های فروش فعلی"}),a.jsx("input",{type:"text",value:i.salesChannels||"",onChange:e=>o({...i,salesChannels:e.target.value}),placeholder:"مثال: تلفنی، اینستاگرام، تایم فور فان",className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"بزرگ‌ترین درد و چالش"}),a.jsx("input",{type:"text",value:i.biggestPain||"",onChange:e=>o({...i,biggestPain:e.target.value}),placeholder:"مثال: کنسلی‌های لحظه آخری و نبود مشتری وسط هفته",className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"خواست و هدف قلبی مدیر"}),a.jsx("input",{type:"text",value:i.coreDesire||"",onChange:e=>o({...i,coreDesire:e.target.value}),placeholder:"مثال: پر شدن سانس‌های خالی بدون هزینه اولیه سنگین",className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[a.jsx("label",{className:"text-xs font-semibold text-teal-800 block mb-1",children:"قلاب اختصاصی اکیپا برای این مجموعه (Hook)"}),a.jsx("input",{type:"text",value:i.hookForEkipa||"",onChange:e=>o({...i,hookForEkipa:e.target.value}),placeholder:"مثال: پر کردن تضمینی سانس‌های بعدازظهر بدون کارمزد ثابت",className:"w-full text-xs px-3 py-2 rounded-xl border border-teal-300 bg-teal-50/50 focus:ring-2 focus:ring-teal-500 font-semibold"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"نوع اعتراض مطرح‌شده"}),(0,a.jsxs)("select",{value:i.objectionStatus||"",onChange:e=>o({...i,objectionStatus:e.target.value}),className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500",children:[a.jsx("option",{value:"",children:"بدون اعتراض خاص"}),Object.keys(ec).map(e=>a.jsx("option",{value:e,children:e},e))]})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-600 block mb-1",children:"قالب پیامک پیشنهادی"}),a.jsx("input",{type:"text",value:i.smsTag||"",onChange:e=>o({...i,smsTag:e.target.value}),placeholder:"sms_proposal_welcome",className:"w-full text-xs px-3 py-2 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 font-mono"})]})]}),a.jsx("div",{className:"pt-2 flex justify-end",children:(0,a.jsxs)("button",{onClick:_,disabled:c,className:"flex items-center gap-2 px-6 py-2.5 bg-purple-600 hover:bg-purple-700 text-white rounded-xl text-xs font-bold shadow transition-all",children:[a.jsx(eD,{className:"w-4 h-4"}),a.jsx("span",{children:c?"در حال ذخیره...":"ذخیره بینش‌های AI"})]})})]})]}),"activities"===n&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("form",{onSubmit:R,className:"bg-white p-5 rounded-2xl border border-slate-200 space-y-3",children:[a.jsx("h3",{className:"font-bold text-sm text-slate-900",children:"ثبت تعامل یا تماس جدید"}),a.jsx("div",{className:"flex gap-2",children:["تماس تلفنی","ارسال پیامک","جلسه حضوری","پیگیری واتساپ"].map(e=>a.jsx("button",{type:"button",onClick:()=>M(e),className:`px-3 py-1.5 rounded-lg text-xs font-medium border transition-colors ${S===e?"bg-slate-900 text-white border-slate-900":"bg-white text-slate-600 border-slate-200"}`,children:e},e))}),a.jsx("textarea",{rows:2,value:z,onChange:e=>$(e.target.value),placeholder:"نتیجه مکالمه یا بازخورد لید را یادداشت کنید...",className:"w-full text-xs p-3 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"}),a.jsx("div",{className:"flex justify-end",children:(0,a.jsxs)("button",{type:"submit",disabled:T,className:"flex items-center gap-1.5 px-4 py-2 bg-teal-600 hover:bg-teal-700 text-white rounded-xl text-xs font-bold transition-all",children:[a.jsx(eu,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:"ثبت در تاریخچه"})]})})]}),a.jsx("div",{className:"space-y-3",children:0===(e.activities||[]).length?a.jsx("p",{className:"text-center text-xs text-slate-400 py-6",children:"هیچ تعاملی ثبت نشده است."}):(e.activities||[]).map(e=>(0,a.jsxs)("div",{className:"bg-white p-4 rounded-xl border border-slate-200 flex items-start gap-3 text-xs",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-50 text-teal-700 flex items-center justify-center shrink-0",children:a.jsx(U,{className:"w-4 h-4"})}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"font-bold text-slate-800",children:e.type}),a.jsx("span",{className:"text-[11px] text-slate-400 font-mono",dir:"ltr",children:new Date(e.createdAt).toLocaleString("fa-IR")})]}),e.notes&&a.jsx("p",{className:"text-slate-600 mt-1 leading-relaxed bg-slate-50 p-2 rounded-lg",children:e.notes}),e.performedBy&&(0,a.jsxs)("span",{className:"text-[10px] text-slate-400 block mt-1",children:["ثبت توسط: ",e.performedBy]})]})]},e.id))})]})]})]})})}function eZ({isOpen:e,onClose:s,onSuccess:t}){if(!e)return null;let[r,n]=(0,l.useState)(""),[d,i]=(0,l.useState)("تهران"),[o,c]=(0,l.useState)(""),[x,m]=(0,l.useState)(""),[h,p]=(0,l.useState)(""),[b,u]=(0,l.useState)(""),[g,j]=(0,l.useState)(""),[f,y]=(0,l.useState)("ارتباط اولیه"),[N,v]=(0,l.useState)(15e6),[w,k]=(0,l.useState)(""),[C,S]=(0,l.useState)(!1),[M,z]=(0,l.useState)(""),$=async e=>{if(e.preventDefault(),!r.trim()||!h.trim()||!d.trim()){z("نام مجموعه، شهر و شماره تماس الزامی هستند.");return}S(!0),z("");try{let e=await fetch("/api/leads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r.trim(),city:d.trim(),district:o.trim()||null,ownerName:x.trim()||"مدیر مجموعه",ownerPhone:h.trim(),managerName:x.trim()||null,phone:h.trim(),stage:f,rooms:w.trim()?[{title:w.trim(),minPlayers:4,maxPlayers:8,ticketPrice:25e4}]:[]})});if(!e.ok){let s=await e.json();throw Error(s.error||"خطا در ثبت لید")}t(),s()}catch(e){z(e.message||"خطا در برقراری ارتباط")}finally{S(!1)}};return a.jsx("div",{className:"fixed inset-0 z-50 bg-slate-900/60 backdrop-blur-sm flex items-center justify-center p-4 overflow-y-auto",children:(0,a.jsxs)("div",{className:"bg-white rounded-3xl shadow-2xl border border-slate-200 w-full max-w-xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",children:[(0,a.jsxs)("div",{className:"p-6 border-b border-slate-100 flex items-center justify-between bg-slate-50",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-600 text-white flex items-center justify-center",children:a.jsx(eB,{className:"w-5 h-5"})}),(0,a.jsxs)("div",{children:[a.jsx("h2",{className:"text-base font-bold text-slate-900",children:"افزودن مجموعه اتاق فرار جدید"}),a.jsx("p",{className:"text-xs text-slate-500",children:"ثبت لید جدید در پایپ‌لاین فروش اکیپا"})]})]}),a.jsx("button",{onClick:s,className:"p-2 text-slate-400 hover:text-slate-700 hover:bg-slate-200/50 rounded-xl transition-colors",children:a.jsx(eW,{className:"w-5 h-5"})})]}),(0,a.jsxs)("form",{onSubmit:$,className:"p-6 space-y-4",children:[M&&a.jsx("div",{className:"p-3 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-xs font-semibold",children:M}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"md:col-span-2",children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:["نام مجموعه / اتاق فرار ",a.jsx("span",{className:"text-rose-500",children:"*"})]}),a.jsx("input",{type:"text",required:!0,value:r,onChange:e=>n(e.target.value),placeholder:"مثال: اتاق فرار طاعون سیاه",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:["شهر ",a.jsx("span",{className:"text-rose-500",children:"*"})]}),a.jsx("input",{type:"text",required:!0,value:d,onChange:e=>i(e.target.value),placeholder:"تهران / کرج / اصفهان ...",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"منطقه / محله"}),a.jsx("input",{type:"text",value:o,onChange:e=>c(e.target.value),placeholder:"مثال: سعادت‌آباد، فردیس",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"نام مدیر یا مسئول"}),a.jsx("input",{type:"text",value:x,onChange:e=>m(e.target.value),placeholder:"مثال: احسان رضایی",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:["شماره تماس ",a.jsx("span",{className:"text-rose-500",children:"*"})]}),a.jsx("input",{type:"text",required:!0,dir:"ltr",value:h,onChange:e=>p(e.target.value),placeholder:"09123456789",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"آیدی اینستاگرام"}),a.jsx("input",{type:"text",dir:"ltr",value:b,onChange:e=>u(e.target.value),placeholder:"@escaperoom_ir",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"وب‌سایت / پلتفرم رزرو"}),a.jsx("input",{type:"text",dir:"ltr",value:g,onChange:e=>j(e.target.value),placeholder:"https://t4f.ir/...",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"مرحله ورود به پایپ‌لاین"}),a.jsx("select",{value:f,onChange:e=>y(e.target.value),className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500 font-semibold",children:eo.map((e,s)=>a.jsx("option",{value:e.stage,children:e.stage},s))})]}),(0,a.jsxs)("div",{children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"ارزش بالقوه قرارداد (تومان)"}),a.jsx("input",{type:"number",value:N,onChange:e=>v(Number(e.target.value)),className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]}),(0,a.jsxs)("div",{className:"md:col-span-2",children:[a.jsx("label",{className:"text-xs font-semibold text-slate-700 block mb-1",children:"نام اولین اتاق فعال مجموعه (اختیاری)"}),a.jsx("input",{type:"text",value:w,onChange:e=>k(e.target.value),placeholder:"مثال: اتاق جن‌گیر (۶ نفره - ۲۵۰,۰۰۰ تومان)",className:"w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500"})]})]}),(0,a.jsxs)("div",{className:"pt-4 border-t border-slate-100 flex items-center justify-end gap-3",children:[a.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 text-xs font-semibold text-slate-600 hover:bg-slate-100 rounded-xl transition-colors",children:"انصراف"}),(0,a.jsxs)("button",{type:"submit",disabled:C,className:"flex items-center gap-1.5 px-6 py-2.5 bg-teal-600 hover:bg-teal-700 text-white text-xs font-bold rounded-xl shadow transition-all active:scale-95",children:[a.jsx(P,{className:"w-4 h-4"}),a.jsx("span",{children:C?"در حال ثبت...":"ثبت مجموعه در CRM"})]})]})]})]})})}function eY(){let[e,s]=(0,l.useState)("dashboard"),[t,r]=(0,l.useState)(!0),[n,d]=(0,l.useState)(null),[i,o]=(0,l.useState)([]),[c,x]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[p,b]=(0,l.useState)(!1),[u,g]=(0,l.useState)(!1),j=async()=>{try{let[e,s,t]=await Promise.all([fetch("/api/dashboard/stats"),fetch("/api/leads"),fetch("/api/tasks/today")]);e.ok&&d(await e.json()),s.ok&&o(await s.json()),t.ok&&x(await t.json())}catch(e){console.error("Error fetching CRM data:",e)}finally{r(!1)}},f=async e=>{try{let s=await fetch(`/api/leads/${e.id}`);if(s.ok){let e=await s.json();h(e)}else h(e)}catch{h(e)}b(!0)};return(0,a.jsxs)("div",{className:"min-h-screen bg-slate-50 flex flex-col font-sans selection:bg-teal-100 selection:text-teal-900",children:[a.jsx(A,{activeTab:e,setActiveTab:s,onNewLead:()=>g(!0),onExportExcel:()=>{window.open("/api/export","_blank")},onImportSuccess:j}),a.jsx("main",{className:"flex-1 max-w-7xl w-full mx-auto p-4 md:p-6 pb-16",children:t?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-32 space-y-4",children:[a.jsx("div",{className:"w-12 h-12 border-4 border-teal-600 border-t-transparent rounded-full animate-spin"}),a.jsx("p",{className:"text-sm font-semibold text-slate-500",children:"در حال بارگذاری اطلاعات CRM اکیپا..."})]}):(0,a.jsxs)(a.Fragment,{children:["dashboard"===e&&a.jsx(es,{stats:n,onSelectLead:f,onNavigateTab:e=>s(e)}),"pipeline"===e&&a.jsx(em,{leads:i,onSelectLead:f,onRefresh:j}),"today"===e&&a.jsx(ek,{data:c,onSelectLead:f,onRefresh:j}),"onboarding"===e&&a.jsx(eM,{leads:i,onSelectLead:f,onRefresh:j}),"settings"===e&&a.jsx(eH,{stats:n,onRefresh:j})]})}),a.jsx(eX,{lead:m,isOpen:p,onClose:()=>{b(!1),h(null)},onRefresh:j}),a.jsx(eZ,{isOpen:u,onClose:()=>g(!1),onSuccess:j})]})}},4403:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>r,metadata:()=>l});var a=t(2051);t(7272);let l={title:"سامانه CRM اکیپا | مدیریت فروش و آنبوردینگ اتاق‌های فرار",description:"سیستم هوشمند ارتباط با مشتریان و اتوماسیون پیگیری اختصاصی اتاق‌های فرار اکیپا"};function r({children:e}){return a.jsx("html",{lang:"fa",dir:"rtl",children:a.jsx("body",{className:"min-h-screen bg-slate-50 text-slate-900 font-vazir antialiased selection:bg-sky-500 selection:text-white",children:e})})}},8646:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>a});let a=(0,t(5347).createProxy)(String.raw`/workspace/personal/crm/app/page.tsx#default`)},7272:()=>{}};var s=require("../webpack-runtime.js");s.C(e);var t=e=>s(s.s=e),a=s.X(0,[787,39],()=>t(7285));module.exports=a})();