PageSourceSearch

https://lidomatrip.com/_next/static/chunks/pages/admin/crm/[id]-c92376446dc28a4c.js

js lidomatrip.com collected 2026-10-02 20:25:52 UTC 50,798 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5668],{68690:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/crm/[id]",function(){return a(15826)}])},99534:function(e,t,a){"use strict";a.d(t,{$4:function(){return j},Af:function(){return b},Gu:function(){return y},Hy:function(){return s},IU:function(){return h},LH:function(){return u},Mz:function(){return l},NA:function(){return v},OV:function(){return m},Qq:function(){return p},SZ:function(){return c},VT:function(){return d},Ve:function(){return w},Zr:function(){return g},_V:function(){return o},aq:function(){return C},i0:function(){return N},nO:function(){return x},xn:function(){return i},yI:function(){return r},yS:function(){return f}});var n=a(84858);let r=()=>(0,n.SC)("/api/admin/crm/stages"),s=e=>(0,n.SC)("/api/admin/crm/stages",{method:"POST",body:JSON.stringify({title:e})}),i=(e,t)=>(0,n.SC)(`/api/admin/crm/stages/${e}`,{method:"PATCH",body:JSON.stringify({title:t})}),l=(e,t)=>(0,n.SC)(`/api/admin/crm/stages/${e}/move`,{method:"POST",body:JSON.stringify({direction:t})}),o=e=>(0,n.SC)(`/api/admin/crm/stages/${e}`,{method:"DELETE"}),c=e=>{let{filter:t,q:a,minStars:r,tags:s}=e,i=new URLSearchParams({filter:t});return a&&i.set("q",a),r&&i.set("minStars",String(r)),(null==s?void 0:s.length)&&i.set("tags",s.join(",")),(0,n.SC)(`/api/admin/crm/board?${i.toString()}`)},d=e=>(0,n.SC)("/api/admin/crm/cards/search-phone",{method:"POST",body:JSON.stringify({phone:e})}),u=e=>(0,n.SC)("/api/admin/crm/cards",{method:"POST",body:JSON.stringify(e)}),x=e=>(0,n.SC)(`/api/admin/crm/cards/${e}`),m=(e,t)=>(0,n.SC)(`/api/admin/crm/cards/${e}`,{method:"PATCH",body:JSON.stringify(t)}),p=(e,t,a)=>(0,n.SC)(`/api/admin/crm/cards/${e}/stage`,{method:"PATCH",body:JSON.stringify({stageId:t,order:a})}),h=(e,t)=>{let a=new URLSearchParams;return Object.entries(t).forEach(e=>{let[t,n]=e;void 0!==n&&""!==n&&a.set(t,Array.isArray(n)?n.join(","):String(n))}),(0,n.SC)(`/api/admin/crm/cards/${e}/search-residences?${a.toString()}`)},g=e=>(0,n.SC)(`/api/admin/crm/neighborhoods${e?`?cityId=${e}`:""}`),y=e=>(0,n.SC)(`/api/admin/crm/cards/${e}/residences`),b=(e,t)=>(0,n.SC)(`/api/admin/crm/cards/${e}/residences`,{method:"POST",body:JSON.stringify({residenceId:t})}),f=(e,t)=>(0,n.SC)(`/api/admin/crm/cards/${e}/residences/${t}`,{method:"DELETE"}),N=e=>(0,n.SC)(`/api/admin/crm/cards/${e}/residences`,{method:"DELETE"}),j=e=>(0,n.SC)(`/api/admin/crm/cards/${e}/send-link`,{method:"POST"}),v=(e,t)=>(0,n.SC)(`/api/admin/crm/cards/${e}/residences/${t}/send-link`,{method:"POST"}),C=(e,t)=>(0,n.SC)(`/api/admin/crm/cards/${e}/reservation`,{method:"POST",body:JSON.stringify({residenceId:t})}),w=e=>(0,n.SC)(`/api/admin/crm/cards/${e}/guest-history`)},19365:function(e,t,a){"use strict";a.d(t,{n:function(){return s}});var n=a(85893),r=a(67294);function s(e){let{value:t,onChange:a}=e,[s,i]=(0,r.useState)(null),l=s??t??0;return(0,n.jsx)("span",{className:"inline-flex items-center gap-x-2",onMouseLeave:()=>i(null),children:[1,2,3].map(e=>(0,n.jsx)("button",{type:"button",onMouseEnter:()=>i(e),onClick:n=>{n.stopPropagation(),a(t===e?null:e)},className:"leading-none","aria-label":`${e} ستاره`,children:(0,n.jsx)("i",{className:`${e<=l?"icon-StarFill text-[#FFB800]":"icon-Star text-gray-D2D2D7"} text-14`})},e))})}},18730:function(e,t,a){"use strict";a.d(t,{Ps:function(){return s},U4:function(){return i},sM:function(){return r}});var n=a(85893);let r=[{value:"NO_DOCS",label:"بدون مدارک"},{value:"POOL",label:"استخردار"},{value:"PARKING",label:"پارکینگ دار"},{value:"LUXURY",label:"لوکس"},{value:"CHEAP",label:"ارزان"}],s={NO_DOCS:{bg:"#F0F0F0",text:"#6C6A7D",border:"#C4CAD3"},POOL:{bg:"#E8F1FF",text:"#1B4F9C",border:"#5B9BFF"},PARKING:{bg:"#FFF4E0",text:"#B26A00",border:"#FFB74D"},LUXURY:{bg:"#F1EAFE",text:"#5B32B0",border:"#B18AF0"},CHEAP:{bg:"#03D6BB14",text:"#015046",border:"#03D6BB"}};function i(e){let{options:t,value:a,onChange:r}=e;return(0,n.jsx)("div",{className:"flex flex-wrap gap-8",children:t.map(e=>{let t=a.includes(e.value),i=s[e.value]??s.NO_DOCS;return(0,n.jsx)("button",{type:"button","aria-pressed":t,onClick:()=>{var t;return t=e.value,void r(a.includes(t)?a.filter(e=>e!==t):[...a,t])},style:t?{backgroundColor:i.bg,color:i.text,borderColor:i.border}:void 0,className:`px-14 py-8 rounded-10 text-13 leading-20 border transition ${t?"font-m":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:e.label},e.value)})})}},1965:function(e,t,a){"use strict";a.d(t,{Z:function(){return u}});var n=a(85893),r=a(67294),s=a(44389),i=a(84858),l=a(32474);let o=["DRAFT","HOST_APPROVAL","SECOND_PAYMENT","DONE"],c={DRAFT:"ثبت درخواست",HOST_APPROVAL:"تایید میزبان",SECOND_PAYMENT:"پرداخت مهمان",DONE:"قطعی",CANCEL:"لغو",EXPIRED:"منقضی"},d={DRAFT:"در انتظار ثبت درخواست",HOST_APPROVAL:"در انتظار تایید میزبان",SECOND_PAYMENT:"در انتظار پرداخت مهمان",DONE:"قطعی",CANCEL:"لغو شده",EXPIRED:"منقضی شده"};function u(e){let{reservationId:t,createdAt:a,updatedAt:u,onCancel:x,onChanged:m}=e,{data:p,mutate:h}=(0,s.u)(`/api/admin/reservations/${t}/state`,e=>(0,i.SC)(e)),[g,y]=(0,r.useState)(null),[b,f]=(0,r.useState)(!1),[N,j]=(0,r.useState)(""),[v,C]=(0,r.useState)(!0),[w,S]=(0,r.useState)(!1),[A,E]=(0,r.useState)(null);if(!p)return(0,n.jsx)(l.Od,{className:"h-[92px]"});let k=o.indexOf(p.current),F="CANCEL"===p.current||"EXPIRED"===p.current,D=new Map(p.allowed.map(e=>[e.state,e.label]));async function O(){if(g){S(!0),E(null);try{await (0,i.SC)(`/api/admin/reservations/${t}/state`,{method:"POST",body:JSON.stringify({toState:g.state,note:N.trim(),notify:v})}),y(null),h(),m()}catch(e){E(e instanceof Error?e.message:"تغییر وضعیت انجام نشد")}finally{S(!1)}}}return(0,n.jsxs)(l.Zb,{className:"p-16",children:[(0,n.jsxs)("div",{className:"flex items-center gap-x-16 flex-wrap gap-y-12",children:[(0,n.jsx)("div",{className:"flex items-center gap-x-8 shrink-0",children:(0,n.jsx)(l.Ct,{tone:F?"red":"DONE"===p.current?"green":"yellow",children:p.current_label})}),(0,n.jsxs)("div",{className:`flex items-center gap-x-4 flex-1 min-w-[320px] ${F?"opacity-50":""}`,children:[o.map((e,t)=>{let a=e===p.current,r=D.has(e),s=!F&&t<k;return(0,n.jsxs)("div",{className:"flex items-center gap-x-4 flex-1 last:flex-initial",children:[(0,n.jsx)("button",{type:"button",disabled:!r,onClick:()=>(function(e,t){if("CANCEL"===e){x();return}y({state:e,label:t}),f(!1),j(""),C(!0),E(null)})(e,D.get(e)??d[e]),title:a?"وضعیت فعلی":r?`انتقال به \xab${d[e]}\xbb`:"از وضعیت فعلی این انتقال مجاز نیست",className:`px-10 py-6 rounded-8 text-12 leading-18 whitespace-nowrap border transition ${a?"bg-primary-main text-white border-primary-main font-m":s?"bg-primary-light text-primary-dark border-primary-light":"bg-gray-F5F5F7 text-gray-9B9BAA border-gray-F5F5F7"} ${r?"cursor-pointer hover:border-primary-main hover:text-primary-dark":"cursor-default"}`,children:c[e]}),t<o.length-1&&(0,n.jsx)("div",{className:`h-2 flex-1 rounded-full ${s?"bg-primary-main":"bg-gray-F0F0F0"}`})]},e)}),D.has("EXPIRED")||F?(0,n.jsx)("span",{className:`mr-10 px-10 py-6 rounded-8 text-12 leading-18 whitespace-nowrap border ${F?"bg-[#FFEBEB] text-[#C62828] border-[#FFEBEB] font-m":"bg-gray-F5F5F7 text-gray-9B9BAA border-gray-F5F5F7"}`,children:c["EXPIRED"===p.current?"EXPIRED":"CANCEL"]}):null]}),(0,n.jsxs)("span",{className:"text-11 leading-18 text-gray-9B9BAA whitespace-nowrap",children:["ثبت ",(0,l.IY)(a)," \xb7 آخرین تغییر ",(0,l.IY)(u)]})]}),!F&&(0,n.jsx)("p",{className:"mt-10 text-11 leading-18 text-gray-9B9BAA",children:"برای تغییر وضعیت، روی مرحله‌ی مقصد کلیک کنید. مراحل غیرفعال از وضعیت فعلی مجاز نیستند."}),(0,n.jsx)(l.u_,{open:!!g,onClose:()=>
1y(null),title:b?"توضیح تغییر وضعیت":"آیا مطمئن هستید؟",width:"max-w-[520px]",children:b?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("textarea",{value:N,onChange:e=>j(e.target.value),rows:3,placeholder:"چرا این رزرو جابه‌جا می‌شود؟",className:"w-full rounded-10 border border-gray-E5E5E6 p-12 text-13 leading-22 outline-none focus:border-primary-main"}),(0,n.jsx)("p",{className:"mt-6 text-11 leading-18 text-gray-9B9BAA",children:"این توضیح در تاریخچه‌ی رزرو با نام شما ثبت می‌شود و پاک نمی‌شود."}),(0,n.jsxs)("label",{className:"flex items-start gap-x-10 mt-14 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:v,onChange:e=>C(e.target.checked),className:"w-16 h-16 mt-2 accent-[#03D6BB]"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("span",{className:"block text-13 leading-22 text-black",children:"اطلاع‌رسانی به مهمان و میزبان"}),(0,n.jsx)("span",{className:"block text-11 leading-18 text-gray-9B9BAA",children:"اعلان درون‌سایتی ارسال می‌شود. سرویس پیامک هنوز وصل نیست، پس فعلاً پیامکی فرستاده نمی‌شود."})]})]}),A&&(0,n.jsx)("p",{className:"mt-10 text-13 text-[#C62828]",children:A}),(0,n.jsxs)("div",{className:"flex justify-end gap-x-8 mt-16",children:[(0,n.jsx)(l.zx,{variant:"secondary",onClick:()=>f(!1),children:"بازگشت"}),(0,n.jsx)(l.zx,{disabled:w||N.trim().length<3,onClick:O,children:w?"در حال ثبت...":"ثبت تغییر وضعیت"})]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("p",{className:"text-14 leading-24 text-black",children:["وضعیت این رزرو از \xab",p.current_label,"\xbb به \xab",g&&d[g.state],"\xbb تغییر می‌کند."]}),(0,n.jsx)("p",{className:"mt-8 text-12 leading-20 text-gray-6C6A7D",children:(null==g?void 0:g.state)==="DONE"?"با این کار سهم میزبان در کیف پولش ثبت می‌شود.":(null==g?void 0:g.state)==="DRAFT"||(null==g?void 0:g.state)==="EXPIRED"?"با این کار شب‌های این رزرو در تقویم آزاد می‌شوند.":"مهلت این مرحله از تنظیمات رزرواسیون دوباره تنظیم می‌شود."}),(0,n.jsxs)("div",{className:"flex justify-end gap-x-8 mt-16",children:[(0,n.jsx)(l.zx,{variant:"secondary",onClick:()=>y(null),children:"انصراف"}),(0,n.jsx)(l.zx,{onClick:()=>f(!0),children:"بله، ادامه"})]})]})})]})}},60063:function(e,t,a){"use strict";a.d(t,{t:function(){return n}});let n={urban:"شهری",rural:"روستایی",suburb:"حومه شهر",beach:"ساحلی",jungle:"جنگلی",mountain:"کوهستانی",desert:"بیابانی"}},15826:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return L}});var n=a(85893),r=a(67294),s=a(11163),i=a(41664),l=a.n(i),o=a(44389),c=a(49759),d=a(32474),u=a(84858),x=a(55290),m=a(33496),p=a(1965),h=a(99534);function g(e){let{value:t,onChange:a}=e,[s,i]=(0,r.useState)((null==t?void 0:t.name)??""),[l,c]=(0,r.useState)(!1),{data:d}=(0,o.u)("/api/admin/cities",e=>(0,u.SC)(e));(0,r.useEffect)(()=>{i((null==t?void 0:t.name)??"")},[null==t?void 0:t.id,null==t?void 0:t.name]);let x=(0,r.useMemo)(()=>{if(!d)return[];let e=s.trim();return e?d.filter(t=>t.name.includes(e)).slice(0,20):d.slice(0,20)},[d,s]);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{value:s,onChange:e=>{i(e.target.value),c(!0),e.target.value||a(null)},onFocus:()=>c(!0),onBlur:()=>setTimeout(()=>c(!1),150),placeholder:"شهر مقصد",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"}),l&&x.length>0&&(0,n.jsx)("div",{className:"absolute z-30 top-full mt-4 w-full max-h-[240px] overflow-y-auto bg-white rounded-12 border border-gray-E5E5E6 shadow-[0_8px_24px_rgba(24,39,58,0.14)] py-6",children:x.map(e=>{var t;return(0,n.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>{a({id:e.id,name:e.name}),i(e.name),c(!1)},className:"w-full px-14 py-8 text-13 leading-20 text-black hover:bg-gray-F5F5F7 text-right",children:[e.name,(null===(t=e.parent)||void 0===t?void 0:t.name)&&(0,n.jsxs)("span",{className:"text-gray-9B9BAA",children:[" / ",e.parent.name]})]},e.id)})})]})}function y(e){let{cityId:t,value:a,onChange:s}=e,[i,l]=(0,r.useState)((null==a?void 0:a.name)??""),[c,d]=(0,r.useState)(!1),{data:u}=(0,o.u)(["crm-neighborhoods",t],()=>(0,h.Zr)(t??void 0));(0,r.useEffect)(()=>
1{l((null==a?void 0:a.name)??"")},[null==a?void 0:a.id,null==a?void 0:a.name]);let x=(0,r.useMemo)(()=>{if(!u)return[];let e=i.trim();return e?u.filter(t=>t.name.includes(e)).slice(0,20):u.slice(0,20)},[u,i]);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{value:i,onChange:e=>{l(e.target.value),d(!0),e.target.value||s(null)},onFocus:()=>d(!0),onBlur:()=>setTimeout(()=>d(!1),150),placeholder:"محله (اختیاری)",className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"}),c&&x.length>0&&(0,n.jsx)("div",{className:"absolute z-30 top-full mt-4 w-full max-h-[240px] overflow-y-auto bg-white rounded-12 border border-gray-E5E5E6 shadow-[0_8px_24px_rgba(24,39,58,0.14)] py-6",children:x.map(e=>{var t;return(0,n.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:()=>{s({id:e.id,name:e.name}),l(e.name),d(!1)},className:"w-full px-14 py-8 text-13 leading-20 text-black hover:bg-gray-F5F5F7 text-right",children:[e.name,(null===(t=e.parent)||void 0===t?void 0:t.name)&&(0,n.jsxs)("span",{className:"text-gray-9B9BAA",children:[" / ",e.parent.name]})]},e.id)})})]})}let b=[{key:"out-guest",label:"با مهمان",direction:"OUTBOUND",party:"GUEST"},{key:"in-guest",label:"از مهمان",direction:"INBOUND",party:"GUEST"},{key:"out-host",label:"با میزبان",direction:"OUTBOUND",party:"HOST"},{key:"in-host",label:"از میزبان",direction:"INBOUND",party:"HOST"}];function f(e){let{open:t,onClose:a,cardId:s,userId:i,onSaved:l}=e,[o,c]=(0,r.useState)(null),[x,m]=(0,r.useState)(""),[p,h]=(0,r.useState)(!1),[g,y]=(0,r.useState)(null);async function f(){let e=x.trim();if(!(e.length<3)){h(!0),y(null);try{o?await (0,u.SC)("/api/admin/activity/calls",{method:"POST",body:JSON.stringify({direction:o.direction,party:o.party,summary:e,crmCardId:s,userId:"GUEST"===o.party?i:null})}):await (0,u.SC)("/api/admin/activity/notes",{method:"POST",body:JSON.stringify({summary:e,crmCardId:s,userId:i})}),m(""),c(null),l(),a()}catch(e){y(e instanceof Error?e.message:"ثبت نشد")}finally{h(!1)}}}return(0,n.jsx)(d.u_,{open:t,onClose:a,title:"افزودن یادداشت یا تماس",children:(0,n.jsxs)("div",{className:"flex flex-col gap-y-12",children:[(0,n.jsx)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-8",children:b.map(e=>{let t=(null==o?void 0:o.key)===e.key;return(0,n.jsx)("button",{type:"button","aria-pressed":t,onClick:()=>c(t?null:e),className:`px-12 py-8 rounded-10 text-13 leading-20 border transition ${t?"border-primary-main bg-primary-light text-primary-dark":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:e.label},e.key)})}),(0,n.jsx)("textarea",{value:x,onChange:e=>m(e.target.value),rows:4,autoFocus:!0,placeholder:o?`شرح ${o.label}`:"متن یادداشت",className:"w-full rounded-12 border border-gray-E5E5E6 p-14 text-14 leading-24 outline-none focus:border-primary-main resize-y"}),g&&(0,n.jsx)("p",{className:"text-13 text-[#C62828]",children:g}),(0,n.jsx)(d.zx,{disabled:p||x.trim().length<3,onClick:f,children:p?"در حال ثبت...":o?"ثبت تماس":"ثبت یادداشت"})]})})}let N={CALL:"تماس",NOTE:"یادداشت",STATE_CHANGE:"تغییر مرحله",FIELD_CHANGE:"تغییر اطلاعات",MESSAGE_SENT:"پیام ارسالی"},j={CALL:"bg-gray-F0F0F0 text-gray-6C6A7D",NOTE:"bg-gray-F0F0F0 text-gray-6C6A7D",STATE_CHANGE:"bg-[#FFF4E0] text-[#B26A00]",FIELD_CHANGE:"bg-[#FFF4E0] text-[#B26A00]",MESSAGE_SENT:"bg-[#F1EAFE] text-[#5B32B0]"};function v(e){let{cardId:t,refreshKey:a}=e,{data:r,isLoading:s}=(0,o.u)(`/api/admin/activity?crmCardId=${t}&take=60&v=${a}`,e=>(0,u.SC)(e)),i=(null==r?void 0:r.items)??[];return(0,n.jsxs)(d.Zb,{className:"p-20",children:[(0,n.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-14",children:"تماس‌ها و رویدادها"}),s?(0,n.jsx)(d.Od,{className:"h-[160px]"}):0===i.length?(0,n.jsx)(d.ub,{text:"رویدادی ثبت نشده"}):(0,n.jsx)("div",{className:"flex flex-col gap-y-10",children:i.map(e=>{var t,a;let r=(null===(t=e.call)||void 0===t?void 0:t.direction)==="OUTBOUND";return(0,n.jsxs)("div",{className:"flex items-start gap-x-12",children:[(0,n.jsx)("span",{className:`w-32 h-32 rounded-10 shrink-0 flex items-center justify-center ${j[e.kind]}`,children:"CALL"===e.kind?(0,n.jsxs)("span",{className:"relative inline-flex text-14",children:[(0,n.jsx)("i",{className:"icon-PhoneFill"}
1),(0,n.jsx)("span",{"aria-hidden":!0,className:`absolute -top-3 ${r?"-left-4":"-right-4"} text-9 leading-9 font-m`,children:r?"↗":"↙"})]}):(0,n.jsx)("i",{className:"icon-Edit text-14"})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-x-8 flex-wrap gap-y-2",children:[(0,n.jsx)("span",{className:`px-8 py-2 rounded-8 text-11 leading-18 ${j[e.kind]}`,children:"CALL"===e.kind?(null===(a=e.call)||void 0===a?void 0:a.label)??"تماس":N[e.kind]}),(0,n.jsx)("span",{className:"text-11 leading-18 text-gray-9B9BAA",children:e.actor_name??"سیستم"}),(0,n.jsxs)("span",{className:"text-11 leading-18 text-gray-9B9BAA mr-auto",children:[(0,d.A1)(e.created_at)[0]," ",(0,d.A1)(e.created_at)[1]]})]}),(0,n.jsx)("p",{className:"text-13 leading-22 text-black break-words whitespace-pre-wrap mt-2",children:e.summary})]})]},e.id)})})]})}function C(e){let{rows:t,mode:a,selected:s,onToggle:i,onOpenRate:l,onRemove:o,onCreateReservation:c,onEditImportance:u,onSendResidenceLink:x,sort:m,onSort:p}=e,[h,g]=(0,r.useState)(null),y="search"===a,b=y?m??null:h;function f(e){y?null==p||p(e):g(t=>(0,d.dx)(t,e))}let N=(0,r.useMemo)(()=>!y&&h?function(e,t){let a="desc"===t.dir?-1:1;return[...e].sort((e,n)=>{switch(t.key){case"name":return a*e.name.localeCompare(n.name,"fa");case"importance":return a*(e.importance-n.importance);case"price":return a*((e.price??0)-(n.price??0));case"host":var r,s;return a*((null===(r=e.host)||void 0===r?void 0:r.name)??"").localeCompare((null===(s=n.host)||void 0===s?void 0:s.name)??"","fa");case"calendarUpdatedAt":return a*((e.calendarUpdatedAt?new Date(e.calendarUpdatedAt).getTime():0)-(n.calendarUpdatedAt?new Date(n.calendarUpdatedAt).getTime():0));case"rooms":return a*(e.roomsCount-n.roomsCount)}})}(t,h):t,[t,y,h]);return(0,n.jsx)("div",{className:"overflow-x-auto",children:(0,n.jsxs)("table",{className:"w-full text-13 leading-20 text-black",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-11 leading-18 text-gray-9B9BAA text-right",children:[(0,n.jsx)("th",{className:"w-32 px-6 py-8"}),(0,n.jsx)("th",{className:"w-32 px-6 py-8"}),(0,n.jsx)("th",{className:"w-32 px-6 py-8",children:"#"}),(0,n.jsx)(d.Re,{label:"اقامتگاه",sortKey:"name",sort:b,onSort:f}),(0,n.jsx)(d.Re,{label:"اهمیت",sortKey:"importance",sort:b,onSort:f}),(0,n.jsx)(d.Re,{label:"قیمت",sortKey:"price",sort:b,onSort:f}),(0,n.jsx)(d.Re,{label:"میزبان",sortKey:"host",sort:b,onSort:f}),(0,n.jsx)("th",{className:"px-6 py-8",children:"تماس میزبان"}),(0,n.jsx)(d.Re,{label:"به‌روزرسانی تقویم",sortKey:"calendarUpdatedAt",sort:b,onSort:f}),(0,n.jsx)(d.Re,{label:"اتاق",sortKey:"rooms",sort:b,onSort:f}),(0,n.jsx)("th",{className:"w-32 px-6 py-8"})]})}),(0,n.jsx)("tbody",{children:N.map((e,t)=>(0,n.jsx)(S,{row:e,index:t,mode:a,checked:(null==s?void 0:s.has(e.id))??!1,onToggle:i,onOpenRate:l,onRemove:o,onCreateReservation:c,onEditImportance:u,onSendResidenceLink:x},e.id))})]})})}function w(e){let{text:t}=e,[a,s]=(0,r.useState)(!1);return(0,n.jsx)("button",{type:"button",onClick:async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1200)}catch{}},title:"کپی شماره",className:"w-20 h-20 rounded-6 inline-flex items-center justify-center text-gray-6C6A7D hover:bg-gray-F0F0F0",children:(0,n.jsx)("i",{className:`${a?"icon-Tick text-[#03D6BB]":"icon-Copy"} text-12`})})}function S(e){var t,a,r,s;let{row:i,index:l,mode:o,checked:c,onToggle:u,onOpenRate:x,onRemove:m,onCreateReservation:p,onEditImportance:h,onSendResidenceLink:g}=e,y="search"===o;return(0,n.jsxs)("tr",{onClick:y?()=>null==u?void 0:u(i.id):void 0,className:`border-t border-gray-F0F0F0 align-top transition ${y?"cursor-pointer":""} ${c?"bg-primary-light/50":"hover:bg-gray-F7F7F7"}`,children:[(0,n.jsx)("td",{className:"px-6 py-10"}),(0,n.jsx)("td",{className:"px-6 py-10",children:(0,n.jsx)("a",{href:i.publicUrl,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),title:"نمایش صفحه اقامتگاه",className:"inline-flex w-20 h-20 items-center justify-center rounded-6 text-gray-6C6A7D hover:bg-gray-F0F0F0 hover:text-primary-main",children:"↗"})}),(0,n.jsx)("td",{className:"px-6 py-10 text-gray-9B9BAA",children:(0,d.N)(l+1)}),(0,n.jsxs)("td",{className:"px-6 py-10 max-w-[220px]",children:[(0,n.jsx)("p",{className:"font-m truncate",title:i.name,children:i.name}),i.address&&(0,n.jsxs)("p",{className:"text-11 leading-16 text-gray-9B9BAA truncate",title:i.address,children:[i.city?`${i.city} — `:"",i.address]})]}),(0,n.jsx)("td",{className:"px-6 py-10",children:(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),h({id:i.id,name:i.name,importance:i.importance})},className:"hover:text-primary-main hover:underline",title:"ویرایش اهمیت",children:(0,d.N)(i.importance)})}),(0,n.jsx)("td",{className:"px-6 py-10 whitespace-nowrap",children:(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),x({id:i.id,name:i.name})},className:"inline-flex items-center gap-x-4 hover:text-primary-main",title:"نرخ‌گذاری کلی",children:[i.price?(0,d.ND)(i.price):"—",(0,n.jsx)("i",{className:"icon-CalendarFlash text-12"})]})}),(0,n.jsx)("td",{className:"px-6 py-10 truncate max-w-[120px]",title:(null===(t=i.host)||void 0===t?void 0:t.name)??"",children:(null===(a=i.host)||void 0===a?void 0:a.name)??"—"}),(0,n.jsx)("td",{className:"px-6 py-10 whitespace-nowrap",dir:"ltr",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-x-4",children:[(null===(r=i.host)||void 0===r?void 0:r.phone)??"—",(null===(s=i.host)||void 0===s?void 0:s.phone)&&(0,n.jsx)(w,{text:i.host.phone})]})}),(0,n.jsx)("td",{className:"px-6 py-10 whitespace-nowrap text-gray-6C6A7D",children:i.calendarUpdatedAt?(0,d.IY)(i.calendarUpdatedAt):"—"}),(0,n.jsx)("td",{className:"px-6 py-10",children:(0,d.N)(i.roomsCount)}),(0,n.jsx)("td",{className:"px-6 py-10",children:"selected"===o?(0,n.jsxs)("div",{className:"flex items-center gap-x-4 justify-end",children:[p&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),p(i.id)},title:"ثبت درخواست رزرو روی این اقامتگاه",className:"px-10 py-6 rounded-8 text-11 leading-16 whitespace-nowrap bg-primary-light text-primary-dark hover:bg-primary-main hover:text-white transition",children:"ثبت درخواست"}),(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),null==m||m(i.id)},title:"حذف از لیست",className:"w-24 h-24 rounded-8 inline-flex items-center justify-center text-[#E53935] hover:bg-[#FFEBEB] shrink-0",children:(0,n.jsx)("i",{className:"icon-Delete text-14"})})]}):g&&(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),g(i.id)},title:"ارسال لینک همین اقامتگاه به مهمان",className:"w-24 h-24 rounded-8 inline-flex items-center justify-center text-gray-6C6A7D hover:bg-primary-light hover:text-primary-dark transition",children:(0,n.jsx)("i",{className:"icon-SendMessage text-14"})})})]})}var A=a(19365),E=a(60063),k=a(18730);let F=[{value:"SUIT",label:"ویلا / سوئیت"},{value:"BOOMGARDI",label:"بوم‌گردی"},{value:"HOTEL",label:"هتل"}],D=[{value:"price_asc",label:"ارزان‌ترین"},{value:"price_desc",label:"گران‌ترین"},{value:"rating_desc",label:"بیشترین امتیاز"},{value:"newest",label:"جدیدترین"},{value:"discount_desc",label:"بیشترین تخفیف"}],O={minPrice:"",maxPrice:"",residenceType:"",tags:[],features:[]};function P(e){let{open:t,onClose:a,value:s,onApply:i}=e,{data:l}=(0,o.u)("/api/admin/amenities",e=>(0,u.SC)(e)),{data:c}=(0,o.u)("/api/admin/rules",e=>(0,u.SC)(e)),[x,m]=(0,r.useState)(s);function p(e){m(t=>({...t,features:t.features.includes(e)?t.features.filter(t=>t!==e):[...t.features,e]}))}function h(e,t,a,r){return(0,n.jsx)("button",{type:"button","aria-pressed":e,onClick:a,className:`px-14 py-8 rounded-10 text-13 leading-20 border transition ${e?"border-primary-main bg-primary-light text-primary-dark font-m":"border-gray-E5E5E6 text-gray-6C6A7D hover:border-gray-C4CAD3"}`,children:t},r)}return(0,r.useEffect)(()=>{t&&m(s)},[t,s]),(0,n.jsx)(d.u_,{open:t,onClose:a,title:"فیلترهای پیشرفته",width:"max-w-[640px]",children:(0,n.jsxs)("div",{className:"flex flex-col gap-y-18 max-h-[70vh] overflow-y-auto",children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-12",children:[(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"حداقل قیمت"}),(0,n.jsx)("input",{inputMode:"numeric",value:x.minPrice,onChange:e=>m(t=>({...t,minPrice:e.target.value.replace(/\D/g,"")})),className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main"})]}),(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"حداکثر قیمت"}),(0,n.jsx)("input",{inputMode:"numeric",value:x.maxPrice,onChange:e=>m(t=>({...t,maxPrice:e.target.value.replace(/\D/g,"")})),className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"نوع اقامتگاه"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-8",children:[h(!x.residenceType,"همه",()=>m(e=>({...e,residenceType:""})),"type-all"),F.map(e=>h(x.residenceType===e.value,e.label,()=>m(t=>({...t,residenceType:e.value})),e.value))]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"وضعیت مدارک / امکانات"}),(0,n.jsx)(k.U4,{options:k.sM,value:x.tags,onChange:e=>m(t=>({...t,tags:e}))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"امکانات اقامتگاه"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-8",children:(l??[]).filter(e=>e.key).map(e=>
1h(x.features.includes(e.key),e.name,()=>p(e.key),`am-${e.id}`))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"مقررات اقامتگاه"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-8",children:(c??[]).filter(e=>e.key).map(e=>h(x.features.includes(e.key),e.name,()=>p(e.key),`rule-${e.id}`))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"منطقه"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-8",children:Object.entries(E.t).map(e=>{let[t,a]=e;return h(x.features.includes(t),a,()=>p(t),`region-${t}`)})})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{className:"block mb-8 text-12 leading-18 text-gray-6C6A7D font-m",children:"ترتیب نمایش"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-8",children:D.map(e=>h(x.order===e.value,e.label,()=>m(t=>({...t,order:t.order===e.value?void 0:e.value})),e.value))})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between pt-4 border-t border-gray-F0F0F0",children:[(0,n.jsx)("button",{type:"button",onClick:()=>m(O),className:"text-13 text-gray-6C6A7D hover:text-black",children:"پاک‌کردن همه"}),(0,n.jsx)(d.zx,{onClick:()=>{i(x),a()},children:"اعمال فیلتر"})]})]})})}function T(e){let{toast:t,onClose:a}=e;if((0,r.useEffect)(()=>{if(!t)return;let e=setTimeout(a,4e3);return()=>clearTimeout(e)},[t,a]),!t)return null;let s=t.tone??"success";return(0,n.jsx)("div",{className:"fixed bottom-24 left-1/2 -translate-x-1/2 z-50 px-20 py-12 rounded-12 shadow-[0_8px_32px_rgba(24,39,58,0.18)] text-13 leading-20 font-m text-white",style:{backgroundColor:"success"===s?"#03B37E":"#E53935"},children:t.text})}let I={DRAFT:{label:"پیش‌نویس",tone:"gray"},HOST_APPROVAL:{label:"در انتظار تایید میزبان",tone:"yellow"},SECOND_PAYMENT:{label:"در انتظار پرداخت نهایی",tone:"yellow"},DONE:{label:"تکمیل شده",tone:"green"},CANCEL:{label:"لغو شده",tone:"red"},EXPIRED:{label:"منقضی شده",tone:"gray"}};function $(e){let{name:t,phone:a}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"text-13 leading-20 text-black",children:t||"بدون نام"}),(0,n.jsx)("div",{className:"text-11 leading-16 text-gray-6C6A7D",dir:"ltr",children:a})]})}function B(e){let{history:t}=e,[a,s]=(0,r.useState)(null);if(0===t.cards.length&&0===t.reservations.length)return null;let i=a?function(e,t){let a="desc"===t.dir?-1:1;return[...e].sort((e,n)=>{switch(t.key){case"reference":return a*e.reference.localeCompare(n.reference,"fa");case"createdAt":return a*(new Date(e.createdAt).getTime()-new Date(n.createdAt).getTime());case"startDate":return a*(new Date(e.startDate).getTime()-new Date(n.startDate).getTime());case"guest":return a*(e.guest.name??"").localeCompare(n.guest.name??"","fa");case"host":return a*(e.host.name??"").localeCompare(n.host.name??"","fa");case"daysCount":return a*(e.daysCount-n.daysCount);case"totalAmount":return a*(e.totalAmount-n.totalAmount);case"paidAmount":return a*(e.paidAmount-n.paidAmount);case"websiteShare":return a*((e.websiteShare??0)-(n.websiteShare??0));case"city":return a*(e.city??"").localeCompare(n.city??"","fa");case"state":return a*e.state.localeCompare(n.state,"fa")}})}(t.reservations,a):t.reservations;return(0,n.jsxs)(d.Zb,{className:"p-20",children:[(0,n.jsx)("h3",{className:"text-16 leading-24 font-m text-black mb-12",children:"درخواست‌ها و رزروهای قبلی این مهمان"}),t.reservations.length>0&&(0,n.jsx)("div",{className:"overflow-x-auto mb-16",children:(0,n.jsxs)("table",{className:"w-full text-13 leading-20 text-black",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"bg-gray-F5F5F7 text-12 leading-18 text-gray-6C6A7D",children:[(0,n.jsx)(d.Re,{label:"کد رزرو",sortKey:"reference",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"ثبت رزرو",sortKey:"createdAt",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"شروع اقامت",sortKey:"startDate",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"مهمان",sortKey:"guest",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"میزبان",sortKey:"host",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}
1),(0,n.jsx)(d.Re,{label:"شب",sortKey:"daysCount",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"مبلغ کل",sortKey:"totalAmount",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"پرداختی",sortKey:"paidAmount",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"سهم لیدوما",sortKey:"websiteShare",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"شهر",sortKey:"city",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"}),(0,n.jsx)(d.Re,{label:"وضعیت",sortKey:"state",sort:a,onSort:e=>s(t=>(0,d.dx)(t,e)),className:"px-12 py-10 font-m whitespace-nowrap"})]})}),(0,n.jsx)("tbody",{className:"divide-y divide-gray-F0F0F0",children:i.map(e=>{let[t,a]=(0,d.A1)(e.createdAt),r=I[e.state];return(0,n.jsxs)("tr",{className:"hover:bg-gray-F5F5F7 transition",children:[(0,n.jsx)("td",{className:"px-12 py-10 whitespace-nowrap",children:(0,n.jsx)(l(),{href:`/admin/reservations/${e.id}`,className:"text-13 font-m text-primary-dark",title:e.residenceName,children:e.reference})}),(0,n.jsxs)("td",{className:"px-12 py-10 whitespace-nowrap",children:[(0,n.jsx)("div",{className:"text-12 leading-18 text-black",children:t}),(0,n.jsx)("div",{className:"text-11 leading-16 text-gray-6C6A7D",children:a})]}),(0,n.jsx)("td",{className:"px-12 py-10 whitespace-nowrap",children:(0,d.IY)(e.startDate)}),(0,n.jsx)("td",{className:"px-12 py-10",children:(0,n.jsx)($,{...e.guest})}),(0,n.jsx)("td",{className:"px-12 py-10",children:(0,n.jsx)($,{...e.host})}),(0,n.jsx)("td",{className:"px-12 py-10",children:(0,d.N)(e.daysCount)}),(0,n.jsx)("td",{className:"px-12 py-10 whitespace-nowrap",children:(0,d.N)(e.totalAmount)}),(0,n.jsxs)("td",{className:"px-12 py-10 whitespace-nowrap",children:[(0,d.N)(e.paidAmount),e.paidAmount<e.totalAmount&&(0,n.jsxs)("div",{className:"text-11 leading-16 text-gray-6C6A7D",children:["مانده ",(0,d.N)(e.totalAmount-e.paidAmount)]})]}),(0,n.jsx)("td",{className:"px-12 py-10 whitespace-nowrap",children:null==e.websiteShare?(0,n.jsx)("span",{className:"text-gray-9B9BAA",children:"—"}):(0,d.N)(e.websiteShare)}),(0,n.jsx)("td",{className:"px-12 py-10 whitespace-nowrap",children:e.city||(0,n.jsx)("span",{className:"text-gray-9B9BAA",children:"—"})}),(0,n.jsx)("td",{className:"px-12 py-10 whitespace-nowrap",children:(0,n.jsx)(d.Ct,{tone:(null==r?void 0:r.tone)??"gray",children:(null==r?void 0:r.label)??e.state})})]},e.id)})})]})}),t.cards.length>0&&(0,n.jsx)("div",{className:"flex flex-col gap-y-6",children:t.cards.map(e=>(0,n.jsxs)(l(),{href:`/admin/crm/${e.id}`,className:"flex items-center justify-between gap-x-8 px-12 py-8 rounded-10 hover:bg-gray-F5F5F7 text-13 leading-20",children:[(0,n.jsx)("span",{className:"text-black",children:"درخواست CRM دیگر"}),(0,n.jsxs)("span",{className:"text-gray-6C6A7D whitespace-nowrap",children:[e.stageTitle," \xb7 ",(0,d.IY)(e.createdAt)]})]},e.id))})]})}function R(e){let{target:t,onClose:a,onSaved:s}=e,[i,l]=(0,r.useState)(""),[c,x]=(0,r.useState)(!1),[m,p]=(0,r.useState)(null);(0,r.useEffect)(()=>{t&&l(String(t.importance))},[t]);let h=""===i?null:Number(i),{data:g}=(0,o.u)(t&&null!=h&&!Number.isNaN(h)?`/api/admin/crm/residence-importance/${t.id}/preview?value=${h}`:null,e=>(0,u.SC)(e));async function y(){if(!(!t||null==h||Number.isNaN(h))){x(!0),p(null);try{await (0,u.SC)(`/api/admin/residences/${t.id}`,{method:"PATCH",body:JSON.stringify({importance:h})}),s(),a()}catch(e){p(e instanceof Error?e.message:"ذخیره نشد")}finally{x(!1)}}}return(0,n.jsx)(d.u_,{open:!!t,onClose:a,title:`اهمیت — ${(null==t?void 0:t.name)??""}`,width:"max-w-[420px]",children:(0,n.jsxs)("div",{className:"flex flex-col gap-y-14",children:[(0,n.jsxs)("label",{className:"block",children:[(0,n.jsx)("span",{className:"block mb-6 text-12 leading-18 text-gray-6C6A7D font-m",children:"مقدار اهمیت"}),(0,n.jsx)("input",{inputMode:"numeric",value:i,onChange:e=>l(e.target.value.replace(/\D/g,"")),className:"w-full px-14 py-10 rounded-10 border border-gray-E5E5E6 text-14 leading-22 outline-none focus:border-primary-main transition"})]}),(0,n.jsx)("div",{className:"rounded-10 bg-gray-F5F5F7 p-14 text-13 leading-22 text-black",children:g?(0,n.jsxs)(n.Fragment,{children:["با این مقدار، این اقامتگاه رتبه‌ی ",(0,n.jsx)("b",{children:(0,d.N)(g.rank)})," از"," ",(0,n.jsx)("b",{children:(0,d.N)(g.total)})," اقامتگاه در ترتیب پیش‌فرض سرچِ",g.cityName?` \xab${g.cityName}\xbb`:" همین شهر"," می‌شود."]}):(0,n.jsx)("span",{className:"text-gray-9B9BAA",children:"در حال محاسبه..."})}),m&&(0,n.jsx)("p",{className:"text-13 text-[#C62828]",children:m}),(0,n.jsx)("div",{className:"flex justify-end",children:(0,n.jsx)(d.zx,{disabled:c||null==h,onClick:y,children:c?"در حال ذخیره...":"ذخیره"})})]})})}function L(){let e=(0,s.useRouter)(),t=Number(e.query.id),a=Number.isInteger(t)&&t>0,{data:i,mutate:b}=(0,o.u)(a?`crm-card-${t}`:null,()=>(0,h.nO)(t)),{data:N}=(0,o.u)("crm-stages",h.yI),{data:j}=(0,o.u)("/api/admin/amenities",e=>(0,u.SC)(e)),{data:w}=(0,o.u)("/api/admin/rules",e=>(0,u.SC)(e)),[S,I]=(0,r.useState)({}),[$,L]=(0,r.useState)(O),[M,U]=(0,r.useState)(!1),[z,K]=(0,r.useState)(""),[H,J]=(0,r.useState)(!1),[Z,G]=(0,r.useState)(null),[X,V]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e,t;if(!i)return;let a={destinationLocationId:i.destinationLocationId,destinationNeighborhoodId:i.destinationNeighborhoodId,tripStartDate:i.tripStartDate?i.tripStartDate.slice(0,10):"",guestsCount:String(i.guestsCount??""),residenceCode:""},n={minPrice:String(i.minPrice??""),maxPrice:String(i.maxPrice??""),residenceType:i.residenceType??"",tags:i.tags??[],features:[]};I({guestName:i.guestName,destinationLocationName:(null===(e=i.destinationLocation)||void 0===e?void 0:e.name)??"",destinationNeighborhoodName:(null===(t=i.destinationNeighborhood)||void 0===t?void 0:t.name)??"",nightsCount:i.nightsCount??"",bedroomsCount:i.bedroomsCount??"",...a}),L(n),K(_(a,n))},[null==i?void 0:i.id]);let[Y,q]=(0,r.useState)(!1),[Q,W]=(0,r.useState)(0),[ee,et]=(0,r.useState)(null),[ea,en]=(0,r.useState)(1),[er,es]=(0,r.useState)(null),[ei,el]=(0,r.useState)(new Set),eo={destinationLocationId:S.destinationLocationId??null,destinationNeighborhoodId:S.destinationNeighborhoodId??null,tripStartDate:S.tripStartDate??"",guestsCount:S.guestsCount??"",residenceCode:S.residenceCode??""},ec=_(eo,$),{data:ed,isLoading:eu,mutate:ex}=(0,o.u)(a&&i&&z?`crm-search-${t}-${ea}-${z}-${(null==er?void 0:er.key)??""}-${(null==er?void 0:er.dir)??""}`:null,()=>
1(0,h.IU)(t,{page:ea,pageSize:10,code:S.residenceCode||void 0,features:$.features,order:$.order,sortBy:null==er?void 0:er.key,sortDir:null==er?void 0:er.dir})),{data:em,mutate:ep}=(0,o.u)(a?`crm-selected-${t}`:null,()=>(0,h.Gu)(t)),{data:eh}=(0,o.u)(a?`crm-guest-history-${t}`:null,()=>(0,h.Ve)(t));if(!a)return null;if(!i)return(0,n.jsx)(c.Z,{children:(0,n.jsx)(d.Od,{className:"h-[400px]"})});async function eg(){U(!0);try{await (0,h.OV)(t,{guestName:S.guestName||null,destinationLocationId:S.destinationLocationId||null,destinationNeighborhoodId:S.destinationNeighborhoodId||null,tripStartDate:S.tripStartDate||null,nightsCount:""===S.nightsCount?null:Number(S.nightsCount),guestsCount:""===S.guestsCount?null:Number(S.guestsCount),bedroomsCount:""===S.bedroomsCount?null:Number(S.bedroomsCount),residenceType:$.residenceType||null,minPrice:""===$.minPrice?null:Number($.minPrice),maxPrice:""===$.maxPrice?null:Number($.maxPrice),tags:$.tags}),b()}finally{U(!1)}}async function ey(){await eg(),en(1),K(ec)}async function eb(e){await (0,h.OV)(t,{stars:e}),b()}async function ef(e){await (0,h.Qq)(t,e,Date.now()),b(),W(e=>e+1)}async function eN(){await Promise.all([...ei].map(e=>(0,h.Af)(t,e))),el(new Set),ep()}async function ej(){try{let e=await (0,h.$4)(t);G({text:e.sent?"لینک برای مهمان پیامک شد":`پیامک ارسال نشد — لینک: ${e.url}`,tone:e.sent?"success":"error"})}catch(e){G({text:e instanceof Error?e.message:"ارسال لینک ناموفق بود",tone:"error"})}}async function ev(e){try{let a=await (0,h.NA)(t,e);G({text:a.sent?"لینک اقامتگاه برای مهمان پیامک شد":`پیامک ارسال نشد — لینک: ${a.url}`,tone:a.sent?"success":"error"})}catch(e){G({text:e instanceof Error?e.message:"ارسال لینک ناموفق بود",tone:"error"})}}async function eC(e){if(window.confirm("درخواست رزرو روی این اقامتگاه ثبت شود؟ این یعنی یک رزرو واقعی برای میزبان ارسال می‌شود."))try{await (0,h.aq)(t,e),G({text:"درخواست رزرو ثبت شد",tone:"success"}),b()}catch(e){G({text:e instanceof Error?e.message:"ثبت درخواست ناموفق بود",tone:"error"})}}async function ew(){let e=null==i?void 0:i.userId;if(!e)return;let t=window.prompt("رمز عبور جدید برای این کاربر (حداقل ۶ کاراکتر)؟");if(t){if(t.length<6){G({text:"رمز عبور باید حداقل ۶ کاراکتر باشد",tone:"error"});return}try{await (0,u.SC)(`/api/admin/users/${e}/password`,{method:"POST",body:JSON.stringify({password:t})}),G({text:"رمز عبور ثبت شد",tone:"success"})}catch(e){G({text:e instanceof Error?e.message:"ثبت رمز عبور ناموفق بود",tone:"error"})}}}let eS=Object.fromEntries((j??[]).filter(e=>e.key).map(e=>[e.key,e.name])),eA=Object.fromEntries((w??[]).filter(e=>e.key).map(e=>[e.key,e.name])),eE=function(e,t,a){var n,r,s;let i=[];if(e.minPrice&&i.push({key:"minPrice",label:`از ${Number(e.minPrice).toLocaleString("fa-IR")} تومان`,clear:e=>({...e,minPrice:""})}),e.maxPrice&&i.push({key:"maxPrice",label:`تا ${Number(e.maxPrice).toLocaleString("fa-IR")} تومان`,clear:e=>({...e,maxPrice:""})}),e.residenceType){let t=(null===(n=F.find(t=>t.value===e.residenceType))||void 0===n?void 0:n.label)??e.residenceType;i.push({key:"residenceType",label:t,clear:e=>({...e,residenceType:""})})}for(let t of e.tags){let e=(null===(r=k.sM.find(e=>e.value===t))||void 0===r?void 0:r.label)??t;i.push({key:`tag-${t}`,label:e,clear:e=>({...e,tags:e.tags.filter(e=>e!==t)})})}for(let n of e.features){let e=t[n]??a[n]??E.t[n]??n;i.push({key:`feature-${n}`,label:e,clear:e=>({...e,features:e.features.filter(e=>e!==n)})})}if(e.order){let t=(null===(s=D.find(t=>t.value===e.order))||void 0===s?void 0:s.label)??e.order;i.push({key:"order",label:`ترتیب: ${t}`,clear:e=>({...e,order:void 0})})}return i}($,eS,eA);return(0,n.jsxs)(c.Z,{title:i.guestName||i.phone,breadcrumb:(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(l(),{href:"/admin/crm",children:"درخواست‌های CRM"})}),backHref:"/admin/crm",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-y-16",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-x-16 flex-wrap gap-y-10",children:[(0,n.jsx)(d.Qm,{tabs:(N??[]).map(e=>({key:String(e.id),label:e.title})),value:String(i.stageId),onChange:e=>ef(Number(e))}),(0,n.jsx)("div",{className:"flex items-center gap-x-8",children:(0,n.jsxs)(d.zx,{variant:"secondary",onClick:()=>q(!0),children:[(0,n.jsx)("i",{className:"icon-Edit text-14"})," افزودن یادداشت / تماس"]})})]}),(0,n.jsxs)(d.Zb,{className:"p-20",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-16",children:[(0,n.jsx)("h2",{className:"text-16 leading-24 font-m text-black",children:"اطلاعات مهمان"}),(0,n.jsxs)("div",{className:"flex items-center gap-x-10",children:[(0,n.jsx)(A.n,{value:i.stars,onChange:eb}),(0,n.jsx)("span",{dir:"ltr",className:"text-13 text-gray-6C6A7D",children:i.phone}),i.userId&&(0,n.jsx)("button",{type:"button",onClick:ew,title:"اختصاص رمز عبور به این کاربر",className:"w-24 h-24 rounded-8 flex items-center justify-center text-gray-6C6A7D hover:bg-gray-F0F0F0",children:(0,n.jsx)("i",{className:"icon-Key text-14"})})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-14",children:[(0,n.jsx)(d.gN,{label:"نام مهمان",children:(0,n.jsx)(d.II,{value:S.guestName??"",onChange:e=>I(t=>({...t,guestName:e.target.value}))})}),(0,n.jsx)(d.gN,{label:"شهر مقصد",children:(0,n.jsx)(g,{value:S.destinationLocationId?{id:S.destinationLocationId,name:S.destinationLocationName}:null,onChange:e=>I(t=>({...t,destinationLocationId:(null==e?void 0:e.id)??null,destinationLocationName:(null==e?void 0:e.name)??""}))})}),(0,n.jsx)(d.gN,{label:"محله",children:(0,n.jsx)(y,{cityId:S.destinationLocationId??null,value:S.destinationNeighborhoodId?{id:S.destinationNeighborhoodId,name:S.destinationNeighborhoodName}:null,onChange:e=>I(t=>({...t,destinationNeighborhoodId:(null==e?void 0:e.id)??null,destinationNeighborhoodName:(null==e?void 0:e.name)??""}))})}),(0,n.jsx)(d.gN,{label:"کد اقامتگاه",hint:"اگر پر شود، فقط همین یک اقامتگاه نشان داده می‌شود",children:(0,n.jsx)(d.II,{inputMode:"numeric",value:S.residenceCode??"",onChange:e=>I(t=>({...t,residenceCode:e.target.value.replace(/\D/g,"")}))})}),(0,n.jsx)(x.ZP,{label:"تاریخ سفر",value:S.tripStartDate??"",onChange:e=>I(t=>({...t,tripStartDate:e}))}),(0,n.jsx)(d.gN,{label:"تعداد شب",children:(0,n.jsx)(d.II,{inputMode:"numeric",value:S.nightsCount??"",onChange:e=>I(t=>({...t,nightsCount:e.target.value.replace(/\D/g,"")}))})}),(0,n.jsx)(d.gN,{label:"تعداد نفرات",children:(0,n.jsx)(d.II,{inputMode:"numeric",value:S.guestsCount??"",onChange:e=>I(t=>({...t,guestsCount:e.target.value.replace(/\D/g,"")}))})}),(0,n.jsx)(d.gN,{label:"تعداد اتاق خواب",children:(0,n.jsx)(d.II,{inputMode:"numeric",value:S.bedroomsCount??"",onChange:e=>I(t=>({...t,bedroomsCount:e.target.value.replace(/\D/g,"")}))})})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-y-10 mt-16",children:[eE.length>0&&(0,n.jsx)("div",{className:"flex flex-wrap gap-8",children:eE.map(e=>(0,n.jsxs)("span",{className:"inline-flex items-center gap-x-6 px-10 py-6 rounded-8 bg-primary-light text-primary-dark text-12 leading-18",children:[e.label,(0,n.jsx)("button",{type:"button",onClick:()=>L(t=>e.clear(t)),"aria-label":"حذف فیلتر",children:"✕"})]},e.key))}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>J(!0),className:"text-13 leading-20 text-primary-dark hover:underline",children:["فیلترهای پیشرفته",eE.length>0&&` (${(0,d.N)(eE.length)})`]}),(0,n.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,n.jsx)(d.zx,{variant:"secondary",onClick:function(){window.confirm("همه‌ی فیلترها و اطلاعاتِ سفر پاک شود؟ فقط نام و شماره‌ی مهمان می‌ماند.")&&(I(e=>({guestName:e.guestName,destinationLocationId:null,destinationLocationName:"",destinationNeighborhoodId:null,destinationNeighborhoodName:"",tripStartDate:"",nightsCount:"",guestsCount:"",bedroomsCount:"",residenceCode:""})),L(O))},children:"پاک‌کردن"}),(0,n.jsx)(d.zx,{disabled:M||!(ec!==z),onClick:ey,children:M?"در حال ذخیره...":"ذخیره و جستجو"})]})]})]})]}),i.reservation&&(0,n.jsx)(p.Z,{reservationId:i.reservation.id,createdAt:i.reservation.createdAt,updatedAt:i.reservation.updatedAt,onCancel:()=>e.push(`/admin/reservations/${i.reservation.id}`),onChanged:()=>b()}),em&&em.length>0&&(0,n.jsxs)(d.Zb,{className:"p-20",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-14",children:[(0,n.jsx)("h2",{className:"text-16 leading-24 font-m text-black",children:"اقامتگاه‌های انتخاب‌شده"}),(0,n.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,n.jsx)(d.zx,{variant:"secondary",onClick:async()=>{window.confirm("کل لیست پاک شود؟")&&(await (0,h.i0)(t),ep())},children:"پاک‌کردن لیست"}),(0,n.jsx)(d.zx,{onClick:ej,children:"ارسال لینک به مهمان"})]})]}),(0,n.jsx)(C,{rows:em,mode:"selected",onOpenRate:et,onRemove:async e=>{await (0,h.yS)(t,e),ep()},onCreateReservation:i.reservationId?void 0:eC,onEditImportance:V})]}),(0,n.jsxs)(d.Zb,{className:"p-20",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-14",children:[(0,n.jsx)("h2",{className:"text-16 leading-24 font-m text-black",children:"اقامتگاه‌های فیلترشده"}),(0,n.jsxs)("div",{className:"flex items-center gap-x-8",children:[(0,n.jsx)("button",{onClick:()=>ex(),title:"بروزرسانی",className:"w-28 h-28 rounded-8 flex items-center justify-center text-gray-6C6A7D hover:bg-gray-F0F0F0",children:(0,n.jsx)("i",{className:"icon-Refresh text-14"})}),(0,n.jsx)("button",{disabled:ea<=1,onClick:()=>en(e=>e-1),className:"w-28 h-28 rounded-8 flex items-center justify-center text-gray-6C6A7D hover:bg-gray-F0F0F0 disabled:opacity-40",children:(0,n.jsx)("i",{className:"icon-FlashRight text-14"})}),(0,n.jsxs)("span",{className:"text-12 text-gray-6C6A7D",children:[(0,d.N)(ea)," / ",(0,d.N)(ed?Math.max(1,Math.ceil(ed.total/ed.pageSize)):1)]}),(0,n.jsx)("button",{disabled:!ed||ea>=Math.ceil(ed.total/ed.pageSize),onClick:()=>en(e=>e+1),className:"w-28 h-28 rounded-8 flex items-center justify-center text-gray-6C6A7D hover:bg-gray-F0F0F0 disabled:opacity-40",children:(0,n.jsx)("i",{className:"icon-FlashLeft text-14"})})]})]}),eu||!ed?(0,n.jsx)(d.Od,{className:"h-[200px]"}):0===ed.items.length?(0,n.jsx)("p",{className:"text-13 text-gray-6C6A7D py-20 text-center",children:"اقامتگاهی با این فیلترها پیدا نشد"}):(0,n.jsx)(C,{rows:ed.items,mode:"search",selected:ei,onToggle:function(e){el(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),a})},onOpenRate:et,onEditImportance:V,onSendResidenceLink:ev,sort:er,onSort:function(e){en(1),es(t=>(0,d.dx)(t,e))}})]}),eh&&(0,n.jsx)(B,{history:eh}),(0,n.jsx)(v,{cardId:t,refreshKey:Q})]}),(0,n.jsx)(f,{open:Y,onClose:()=>q(!1),cardId:t,userId:i.userId,onSaved:()=>{W(e=>e+1),b()}}),(0,n.jsx)(P,{open:H,onClose:()=>J(!1),value:$,onApply:L}),(0,n.jsx)(R,{target:X,onClose:()=>V(null),onSaved:()=>{ex(),ep()}}),(0,n.jsx)(d.u_,{open:!!ee,onClose:()=>et(null),title:`تقویم و نرخ — ${(null==ee?void 0:ee.name)??""}`,width:"max-w-[1280px]",children:ee&&(0,n.jsx)(m.Z,{targets:[{residenceId:ee.id,label:ee.name}],onApplied:()=>{ex(),ep()}})}),(0,n.jsx)(d.XL,{count:ei.size,onClear:()=>el(new Set),actions:[{icon:"icon-Save",label:"ذخیره به عنوان لیست ارسال",onClick:eN}]}),(0,n.jsx)(T,{toast:Z,onClose:()=>G(null)})]})}function _(e,t){return JSON.stringify([e,t.minPrice,t.maxPrice,t.residenceType,t.tags.slice().sort(),t.features.slice().sort(),t.order??null])}}},function(e){e.O(0,[4885,4389,8289,9759,3496,9774,2888,179],function(){return e(e.s=68690)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.